Advertisement
Bolonka

Untitled

Jun 20th, 2023
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4. #include <locale.h>
  5. #include <windows.h>
  6. #include <string.h>
  7.  
  8. #define Alphabet_size 26
  9.  
  10. int main()
  11. {
  12. setlocale(LC_ALL, "Rus");
  13.  
  14. char Alphabet[] = { 'A','B','C','D','E','F','G','H','I','J','K',
  15. 'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', };
  16.  
  17. printf("Введите слово для зашифровки\n");
  18. char Word[21]; // 20 букв и символ конца строки
  19. fgets(Word,21,stdin);
  20. int Word_size = strlen(Word);
  21.  
  22. printf("Введите ключ шифровки от 1 до 25\n");
  23. int Key = getch();
  24.  
  25. for(int i=0; i<Word_size; i++) { // Выбираeтся определенная буква вписанного слова
  26. for (int ii=0; i<Alphabet_size; ii++) { // Определяется эта буква
  27.  
  28. if (Word[i] == Alphabet[ii]) { // Если буква совпадает, происходит смещение
  29.  
  30. Word[i] = Alphabet[ (ii+Key) % Alphabet_size ];
  31. break;
  32. }
  33. }
  34. }
  35.  
  36. puts(Word);
  37. puts("Спасибо");
  38.  
  39. return(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement