Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string text;
  9. int x;
  10.  
  11. cout<<"Enter your phrase:"<<endl;
  12. cin >>text;
  13. cout<<"Enter key: "<<endl;
  14. cin >> x;
  15.  
  16. for(int i=0;i<=text.length();i++){
  17. if(text[i]>=65 && text[i]<=90-x) text[i]=int(text[i])+x; //Block letters
  18. else if(text[i]>=91-x && text[i]<=90) text[i]=int(text[i])-26+x;
  19. else if(text[i]>=97 && text[i]<=122-x) text[i]=int(text[i])+x; //Small letters
  20. else if(text[i]>=123-x && text[i]<=122) text[i]=int(text[i])-26+x;
  21. }
  22. cout << text<<endl;
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement