Advertisement
jacobs1307

playfair

Jan 17th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1.  
  2. public class playfair {
  3.     static char [][] tab= new char[5][5] ;
  4.     public static void tab ()
  5.     {
  6.         int myInt= 65;
  7.         int k=0;
  8.         for (int i = 0; i < tab.length; i++)
  9.         {
  10.             for (int j = 0; j < tab.length; j++)
  11.             {
  12.                 tab[i][j]= (char) (myInt +k);
  13.                 if (k==8) k=k+2;
  14.                 else k++;
  15.                 System.out.println(tab[i][j]);
  16.             }
  17.         }
  18.     }
  19.     public static String szukaj(String x)
  20.     {
  21.        
  22.         String a="";
  23.         for (int i = 0; i < tab.length; i++)
  24.         {
  25.             for (int j = 0; j < tab.length; j++)
  26.             {
  27.                 if ((tab[i][j]+"").equals(x)) a=""+(i+1)+","+(j+1);
  28.                
  29.             }
  30.         }
  31.         return a;
  32.     }
  33.    
  34.     public static void main(String[] args) {
  35.         tab();
  36.         System.out.println(szukaj("B"));
  37.        
  38.        
  39.  
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement