Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <locale.h>
- #include <windows.h>
- #include <string.h>
- #define Alphabet_size 26
- int main()
- {
- setlocale(LC_ALL, "Rus");
- char Alphabet[] = { 'A','B','C','D','E','F','G','H','I','J','K',
- 'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', };
- printf("Введите слово для зашифровки\n");
- char Word[21]; // 20 букв и символ конца строки
- fgets(Word,21,stdin);
- int Word_size = strlen(Word);
- printf("Введите ключ шифровки от 1 до 25\n");
- int Key = getch();
- for(int i=0; i<Word_size; i++) { // Выбираeтся определенная буква вписанного слова
- for (int ii=0; i<Alphabet_size; ii++) { // Определяется эта буква
- if (Word[i] == Alphabet[ii]) { // Если буква совпадает, происходит смещение
- Word[i] = Alphabet[ (ii+Key) % Alphabet_size ];
- break;
- }
- }
- }
- puts(Word);
- puts("Спасибо");
- return(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement