Hey I'm trying to create a simple Vigenere cipher table like this in Java...
http://cairnarvon.rotahall.org/pics/tabularecta.png
I'm doing it for fun but have literally been staring at this code for days now without any brainwaves! If this isn't the right forum, let me know, if you can figure out why the string reaches the boundary do the same!
Thanks for any feedback... Code attached;
public class Main {
public static void main(String[] args) {
char array[][];
array=createTable(27,27,"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
private static char[][] createTable(int x, int y, String s) {
char array[][]=new char[x][y];
int index=0;
array[0][0]=' ';
for(int i=1;i<x;i++){
array[0][i]=s.charAt(index);
index++;
}
index=0;
for(int i=1;i<x;i++){
array[i][0]=s.charAt(index);
index++;
}
index=0;
int column=1;
for(int i=1;i<x;i++){
index=i-1;
for(int j=1;j<column;j++){
array[i][j]=s.charAt(index);
index++;
}
int index2=0;
for(int j=column;j<x;j++){
array[i][j]=s.charAt(index2);
index2++;
}
column++;
}
return array;
}
private static void printTable(char[][] array,int x) {
System.out.println();
for(int i=0;i<x;i++){
for(int j=0;j<x;j++){
System.out.print(array[i][j]+" ");
}
System.out.println();
}
}
}