Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. int main()
  6. {
  7.  
  8. int i,n,x,a;
  9. string str;
  10. char c;
  11. while(1)
  12. {
  13. cin>>n;
  14. if (n==0)
  15. {
  16. break;
  17. }
  18. else
  19. {
  20. cin>>str;
  21. reverse(str.begin(),str.end());
  22. for (i=0; i<str.size(); i++)
  23. {
  24. if (str[i]=='.')
  25. {
  26. a=28;
  27. x = (a+n)%28;
  28.  
  29. if (x==28)
  30. str[i]='.';
  31. else if (x==27)
  32. str[i]='_';
  33. else
  34. str[i] = x+64;
  35. }
  36. else if (str[i]=='_')
  37. {
  38. a=27;
  39. x = (a+n)%28;
  40. if (x==0)
  41. str[i]='.';
  42. else if (x==28)
  43. str[i]='.';
  44. else if (x==27)
  45. str[i]='_';
  46. else
  47. str[i] = x+64;
  48. }
  49. else
  50. {
  51. c = str[i];
  52. a = c-64;
  53. x = (a+n)%28;
  54. if (x==0)
  55. str[i]='.';
  56. else if (x==28)
  57. str[i]='.';
  58. else if (x==27)
  59. str[i]='_';
  60. else
  61. str[i] = x+64;
  62. }
  63. }
  64. cout << str << end1;
  65. return 0;
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement