Zexes
Full Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору [code]// text_shivr.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { char text[200]; int delta, tmp; //Вводим дельту cout << "Delta = ?" << endl; cin >> delta; //Вводим текст для шифровки cout << "Text 2 encrypt:" << endl; cin.get(); cin.getline(text, 200, '\n'); //Стрелка вниз 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)) 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; }[/code] | Всего записей: 553 | Зарегистр. 19-06-2002 | Отправлено: 00:08 24-10-2007 | Исправлено: Zexes, 00:12 24-10-2007 |
|