Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <windows.h>
  5. #define N 30
  6.  
  7. int main()
  8. {
  9.     SetConsoleCP(GetACP());
  10.     SetConsoleOutputCP(GetACP());
  11.  
  12.     int i, j;
  13.     char word[N];
  14.     int shift;
  15.     char alphabet[] = {'A', 'Ą', 'B', 'C', 'Ć', 'D',
  16.                        'E', 'Ę', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
  17.                        'Ł', 'M', 'N', 'Ń', 'O', 'Ó', 'P', 'R', 'S',
  18.                        'Ś', 'T', 'U', 'W', 'X', 'Y', 'Z', 'Ź', 'Ż'
  19.                       };    //33 znaki
  20.  
  21.     printf("Wyraz: ");
  22.     scanf("%s", word);
  23.     printf("Przesuniecie: ");
  24.     scanf("%d", &shift);
  25.  
  26.     for(i=0; i<strlen(word); i++)
  27.     {
  28.         for(j=0; j<strlen(alphabet); j++){
  29.             if(word[i]==alphabet[j]){
  30.                 word[i] = alphabet[ (j+shift) % (strlen(alphabet)-1) ];
  31.                 break;
  32.             }
  33.         }
  34.     }
  35.  
  36.     printf("Zaszyfrowany wyraz: %s", word);
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement