Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string tekst; //zmienna do przechowywania naszego tekstu
  8. int x; // zmienna przechowujaca wspolczynnik przesuniecia <0;26>
  9.  
  10. cout<<"podaj tekst do zaszyfrowania"<<endl;
  11. cin >>tekst;
  12. cout<<"podaj wspolczynnik przesuniecia"<<endl;
  13. cin >> x;
  14.  
  15. for(int i=0;i<=tekst.length();i++)
  16. {
  17. if(tekst[i]>=65 && tekst[i]<=90-x) tekst[i]=tekst[i]+x;
  18. else if(tekst[i]>=91-x && tekst[i]<=90) tekst[i]=tekst[i]-26+x;
  19. }
  20. cout <<"Tekst zaszyfrowany:\t" << tekst << endl;
  21.  
  22. for(int i = 0; i <= tekst.length();i++)
  23. {
  24. if(tekst[i]>=65+x && tekst[i]<=90) tekst[i]=tekst[i]-x;
  25. else if(tekst[i]<=64+x && tekst[i]>=65) tekst[i]=tekst[i]+26-x;
  26. }
  27. cout <<"Tekst odszyfrowany:\t" << tekst << endl;
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement