Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- String[][] tabliczka = new String[3][3];
- tabliczka[0][0]="ELA";
- tabliczka[1][0]="ABA";
- tabliczka[2][0]="ABBA";
- hash(tabliczka);
- }
- public static int[] hash (String[][] tab) throws NullPointerException{
- int[] tablicka = new int[tab.length];
- int wynikk=0;
- for (int i=0;i<tab.length;i++){
- String x = tab[i][0];
- int wynik=0;
- for(int j=0;j<x.length();j++){
- char c = x.charAt(j);
- int ascii = ((int)c)-64;
- wynik = ascii*(j+1);
- wynikk+=wynik;
- }
- int numer = 1;
- do{
- if(tab[i][numer]==null && numer<tab.length){
- tab[i][numer] = Integer.toString(wynikk);
- wynikk=0;
- System.out.println(tab[i][1]);
- numer++;
- }else{
- numer++;
- }
- }while(tab[i][numer]!=null && numer<tab.length);
- }
- return tablicka;
- }
Add Comment
Please, Sign In to add comment