Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <math.h>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <sstream>
- using namespace std;
- int main()
- {
- string s, answer = "";
- cin >> s;
- int prom;
- if (s[0] >= 'A'&& s[0] <= 'Z')
- {
- prom = s[0] +5- 65;
- if (prom> 25)
- answer += (s[0] + 5) % 26+65;
- else
- answer += s[0] + 5;
- }
- else
- {
- prom = s[0]+5 - 97;
- if (prom > 25)
- answer += (s[0]+5)% 26+97;
- else
- answer += s[0] + 5;
- }
- for (int i = 1; i <= s.size() - 1; i++)
- {
- if (s[i] >= 'A'&& s[i] <= 'Z')
- {
- if (s[i] + prom > 90)
- answer += (s[i]-65 + prom) % 26+65;
- else
- answer += s[i] + prom;
- prom = s[i] - 65+prom;
- }
- else
- {
- if (s[i] + prom > 122)
- answer += (s[i]-97 + prom) % 26+97;
- else
- answer += s[i] + prom;
- prom = s[i] - 97+prom;
- }
- }
- cout << answer;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment