Advertisement
rygyfygy

Cezar

Nov 16th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int sprawdz(char znak)
  5. {
  6. if(znak >= 'a'&& znak <= 'z') return 0;
  7. if (znak >= 'A' && znak <= 'Z') return 1;
  8. return 2;
  9. }
  10.  
  11. void szyfruj(int klucz, string &tab)
  12. {
  13. if(!(klucz >= -26 && klucz <= 26))
  14. int pom;
  15. char a, z;
  16.  
  17. for (int i = 0; i < tab.size(); i++)
  18. {pom = sprawdz (tab[i]);
  19. if(pom<2)
  20. if(pom == 0)
  21. a = 'a', z='z';
  22. else
  23. a='A', z='Z';
  24.  
  25. if(klucz >= 0)
  26.  
  27. if(tab[i] + klucz <= z)
  28. tab[i] += klucz;
  29. else tab [i] = tab [i] + klucz - 26;
  30. else
  31. if(tab[i]+klucz>=a)
  32. tab[i]+=klucz;
  33. else tab[i]=tab[i]+klucz+26;
  34. }
  35. }
  36. }
  37. int main(){
  38. string tab;
  39.  
  40. int klucz
  41.  
  42. int x;
  43.  
  44. cout<<"podaj tekst do zaszyfrowania"<<endl;
  45. cin >>tekst;
  46. cout<<"podaj wspolczynnik przesuniecia"<<endl;
  47. cin >> x;
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement