Advertisement
dzieciol

szyfr cezara c++

Oct 27th, 2014
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. string tekst;
  7. int x;
  8.  
  9. cout<<"podaj tekst do zaszyfrowania"<<endl;
  10. cin >>tekst;
  11. cout<<"podaj wspolczynnik przesuniecia"<<endl;
  12. cin >> x;
  13.  
  14. for(int i=0;i<=tekst.length();i++){
  15. if(tekst[i]>=65 && tekst[i]<=90-x) tekst[i]=int(tekst[i])+x;
  16. else if(tekst[i]>=91-x && tekst[i]<=90) tekst[i]=int(tekst[i])-26+x;
  17. }
  18. cout << tekst<<endl;
  19.  system("pause");
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement