Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string text;
- int x;
- cout<<"Enter your phrase:"<<endl;
- cin >>text;
- cout<<"Enter key: "<<endl;
- cin >> x;
- for(int i=0;i<=text.length();i++){
- if(text[i]>=65 && text[i]<=90-x) text[i]=int(text[i])+x; //Block letters
- else if(text[i]>=91-x && text[i]<=90) text[i]=int(text[i])-26+x;
- else if(text[i]>=97 && text[i]<=122-x) text[i]=int(text[i])+x; //Small letters
- else if(text[i]>=123-x && text[i]<=122) text[i]=int(text[i])-26+x;
- }
- cout << text<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement