int _tmain() { char text[200]; int delta, tmp; //Вводим дельту cout << "Delta = ?" << endl; cin >> delta; //Вводим текст для шифровки cout << "Text 2 encrypt:" << endl; cin.get(); // удаляем из потока enter cin.get( text, sizeof text - 1 ); // чтение строки //Стрелка вниз 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; cin.get(); return 0; } |