- [YDRB#002] 一步步脚踏实地 · 云斗九月 Bronze Round
90pts?
- 2024-9-8 11:22:57 @
#include <bits/stdc++.h>
using namespace std;
int key;
char s[300];
int main()
{
scanf("%d\n",&key);
gets(s);
int size = strlen(s);
for(int i = 0;i < size;i++)
{
if(s[i] >= 'a' && s[i] <= 'z')
{
if(s[i] - key >= 'a')
{
s[i] -= key;
}
else
{
int key_next = 'a' - (s[i] - key) - 1;
s[i] = 'z' - key_next;
}
}
if(s[i] >= 'A' && s[i] <= 'Z')
{
if(s[i] - key >= 'A')
{
s[i] -= key;
}
else
{
int key_next = 'A' - (s[i] - key) - 1;
s[i] = 'Z' - key_next;
}
}
}
cout << s << endl;
return 0;
}
0 comments
No comments so far...