int _tmain(int argc, _TCHAR* argv[]) { char text[200]; int delta, tmp; //Вводим дельту cout << "Delta = ?" << endl; cin >> delta; //Вводим текст для шифровки cout << "Text 2 encrypt:" << endl; cin >> gets(text); //Стрелка вниз for (int i=0; i < (strlen(text)/2); i++) cout << " "; cout << char(31) << endl; //Шифр. for (int i=0; i < strlen(text); i++) { if (text[i] == ' ') continue; int n = (int)text[i]; if ((97 <= n) && (n <= 122)) text[i] = (n - 97 + delta)%26 + 97; cout << text[i]; } cout << endl; //Стрелка вниз for (int i=0; i < (strlen(text)/2); i++) cout << " "; cout << char(31) << endl; //Расшифр. for (int i=0; i < strlen(text); i++) { int n = (int)text[i]; if ((97 <= n) && (n <= 122)) { tmp = (n - 97 - delta)%26; if (tmp < 0) tmp += 26; text[i] = tmp + 97; } cout << text[i]; } cout << endl; //Выход из программы cout << "Press any key to exit" << endl; char exit[1]; cin >> gets(exit); return 0; } |