-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplayfair.java
More file actions
61 lines (56 loc) · 1.22 KB
/
playfair.java
File metadata and controls
61 lines (56 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import java.io.*;
class playfair
{
public static void main(String args[])throws IOException
{
String key;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
key = br.readLine();
// Key has text key
char[][] mat = new char[5][5];
int count = 0;
int count2 = 0;
char aplha[] = {'a','b','c','d','e','f','g','h','i','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int loop = 0;
for(int x=0;x<5;x++)
{
for(int y=0;y<5;y++)
{
if(count<key.length())
{
mat[x][y] = key.charAt(count);
loop++;
}
count++;
}
}
System.out.println("Loop is"+loop);
int loop2 = 0;
for(int x=0;x<5;x++)
{
for(int y=0;y<5;y++)
{
if(loop2>=loop)
{
char element = aplha[count2];
if(key.indexOf(element)<0)
{
//element not in string
mat[x][y] = element;
System.out.println("element is"+element);
}
count2++;
}
loop2++;
System.out.println("Loop2 is"+loop2);
}
}
for(int x=0;x<5;x++)
{
for(int y=0;y<5;y++)
{
System.out.println("Location"+x+y+mat[x][y]);
}
}
}
}