bzdzdbzd @ 2023-11-12 18:42:21
using namespace std;
int main()
{ int a;
char c;
cin >> a;
while (cin >> c)
{
if (c + a <=122)
{
c = c + a;
cout <<(char)c;
}
else
{
c = (a+c-122) % 26 + 96;
cout <<(char) c;
}
}
return 0;
}```cpp
by fantastic_grass @ 2023-11-12 19:02:05
这道题是字符串题目,需要用char数组或string来读入数据
by sansesantongshun @ 2023-11-12 19:13:40
字符加法如果超过130左右会溢出,变成负数
by maozutao @ 2023-11-19 17:34:16
@sansesantongshun 怪不得,原来如此,谢谢