Помогите написать програму на C шифр Цезаря. . .
#include <stdio.h>
#include <conio.h>
#include <locale.h>
#define LIMIT 256
void message(short);
int main() {
char str[LIMIT];
unsigned n;
message(1);
fgets(str, LIMIT, stdin);
for (n = 0; str[n]; n++) str[n] += 3;
printf("%s", str);
_getch();
return 0;
}
void message(short command) {
setlocale(LC_CTYPE, "Russian_Russia.1251");
switch (command) {
case 1: printf("Введите строку: "); break;
} setlocale(LC_CTYPE, "English_United States.866");
}
#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;
}