Advertisement
harisha

Untitled

Feb 26th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cstring>
  4. using namespace std;
  5.  
  6. void szyfrCezara(int klucz, char tab[])
  7. {
  8.     int dl = 63;
  9.     for(int i=0;i<dl;i++)
  10.     {
  11.          tab[i] = (tab[i] - 'A' + klucz)%26 + 'A';
  12.     }
  13.      
  14. }
  15. void szyfrRot13(char tab[])
  16. {
  17.     int dl = 63;
  18.     for(int i=0; i<dl;i++)
  19.     {
  20.         if( tab[i] >= 'A' && tab[i] <= 'Z' )
  21.         {
  22.              tab[i] = ( tab[i] + 13 - 'A' ) % 26 + 'A';
  23.         }
  24.     }
  25.    
  26. }
  27.  
  28.  
  29. int main()
  30. {
  31.     char tabpodst[26]={'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'};
  32.     char tab[63]={'R','I','T','B','B','F','O','R','C','V','E','A','F','N','C','T','E','M','V','T','G','Q','R','F','H','E','Z','A','P','C','B','V','B','A','P','H','B','B','P','R','Z','C','L','A','V','S','V','H','T','C','R','L','G','E','L','P','J','T','C','R','U','V','J'};
  33.  
  34.   int klucz = 6;
  35.  
  36.  
  37.     szyfrCezara(-klucz,tab); //deszyfrowanie
  38.     cout<<"Po rozszyfrowaniu: "<<tab<<endl;
  39.     szyfrRot13(tab);
  40.     cout<<"aaa: "<<tab<<endl;
  41.   system("pause");
  42.   return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement