Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1010;
- int main()
- {
- int n, k;
- char s[N];
- scanf("%d%d %s", &n, &k, s);
- k %= 26;
- if (k < 0) k += 26;
- for (int i = 0; s[i]; ++i) {
- if (isupper(s[i]))
- s[i] = ((s[i]-'A')+k)%26 + 'A';
- else if (islower(s[i]))
- s[i] = ((s[i]-'a')+k)%26 + 'a';
- printf("%c", s[i]);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment