Advertisement
Gireada

Decriptare cifrul lui Cezar

Mar 29th, 2018
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <string.h>
  11.  
  12. using namespace std;
  13.  
  14. char nr_lit[26] = {'a','b', 'c', 'd','e', 'f', 'g','h', 'i', 'j','k', 'l', 'm','n', 'o', 'p','q', 'r', 's','t', 'u',
  15.     'v','w', 'x', 'y','z'};
  16.  
  17. int findposition(char a)
  18. {
  19.     int i = 0;
  20.     for(i = 0; i < 26; i++)
  21.     {
  22.         if(a == nr_lit[i])
  23.             break;
  24.     }
  25.     return i;
  26. }
  27.  
  28. int main()
  29. {
  30.    
  31.     char cuvant[45];
  32.     int numar_modulo[45];
  33.     cin>>cuvant;
  34.     for(int k = 26; k >= 0; k--)
  35.     {
  36.         for(int i = 0; i <strlen(cuvant); i++)
  37.         {
  38.             if(cuvant[i] == 'a')
  39.                 cuvant[i] = 'z';
  40.             else
  41.                 cuvant[i] = nr_lit[findposition(cuvant[i])-1];
  42.             cout<<cuvant[i];    
  43.         }
  44.         cout<<endl;
  45.     }
  46.    
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement