社区讨论
求教,为什么80分过不去?
P1914小书童——凯撒密码参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @mi5hlu8v
- 此快照首次捕获于
- 2025/11/19 12:13 4 个月前
- 此快照最后确认于
- 2025/11/19 12:13 4 个月前
CPP
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char str[1000];
int n, i, x, s;
int main()
{
cin >> n;
scanf("%s", &str);
if (n == 26) {
cout << str;
return 0;
}
x = strlen(str);
for (i = 0;i < x;i++) {
if (str[i] >= 'A' && str[i] <= 'Z') str[i] = char(int(str[i]) + 'a' - 'A');
if (str[i] == 'z') str[i] = char(96);
s = int(str[i]) + n % 26;
if (s > 122) s = s - 122 + 96;
str[i] = char(s);
}
cout << str;
return 0;
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...