1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
char plain[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z' };
char cipher[] = { 'E', 'M', 'N', 'V', 'D', 'L', 'W', 'A', 'U',
'C', 'P', 'O', 'K', 'X', 'Q', 'B', 'I', 'Z', 'J', 'R', 'Y', 'T',
'G', 'S', 'H', 'F' };
char space_cipher[] = {'^', '~', '#', '`', ':'};
while (getline(fileIn, line)) {
int space_i = 0;
for (int i = 0; i <= line.length(); i++) {
line[i] = toupper(line[i]);
if (line[i] == ' ') {
line[i] = space_cipher[space_i];
space_i = (space_i + 1) % 5;
}
fileOut.put(line[i]);
fileOut << endl;
}
cout << line << endl;
}
|