#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char *CaesarCipher (char *str)
{
int i, c;
for (i = 0; str[ i ] != '\0'; i++)
{
c = tolower(str[ i ]);
if (c == 'x') str[ i ] = 'a';
else if (c == 'y') str[ i ] = 'b';
else if (c == 'z') str[ i ] = 'c';
else if (c == ' ') str[ i ] = ' ';
else str[ i ] = c + 3;
}
return str;
}
int main (void)
{
/* тестовые строки взяты с Wiki
http://en.wikipedia.org/wiki/Caesar_cipher */
char str[ ] = "the quick brown fox jumps over the lazy dog";
char test[ ] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
printf("PLAIN : %s\n", test);
printf("CIPHER: %s\n\n", CaesarCipher(test));
printf("Plaintext : ");
puts(str);
printf("Ciphertext : ");
puts(CaesarCipher(str));
system("pause > nul");
return 0;
}