Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- string tekst; //zmienna do przechowywania naszego tekstu
- int x; // zmienna przechowujaca wspolczynnik przesuniecia <0;26>
- cout<<"podaj tekst do zaszyfrowania"<<endl;
- cin >>tekst;
- cout<<"podaj wspolczynnik przesuniecia"<<endl;
- cin >> x;
- for(int i=0;i<=tekst.length();i++)
- {
- if(tekst[i]>=65 && tekst[i]<=90-x) tekst[i]=tekst[i]+x;
- else if(tekst[i]>=91-x && tekst[i]<=90) tekst[i]=tekst[i]-26+x;
- }
- cout <<"Tekst zaszyfrowany:\t" << tekst << endl;
- for(int i = 0; i <= tekst.length();i++)
- {
- if(tekst[i]>=65+x && tekst[i]<=90) tekst[i]=tekst[i]-x;
- else if(tekst[i]<=64+x && tekst[i]>=65) tekst[i]=tekst[i]+26-x;
- }
- cout <<"Tekst odszyfrowany:\t" << tekst << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement