Frank_Ron @ 2021-07-22 08:28:18
如标题,代码如下
#include <cstdio>
#include <iostream>
using namespace std;
char input[50];
int temp[50];
int main() {
int n;
scanf("%d\n", &n);
for (int i = 0; i < 50; i++) {
scanf("%c", &input[i]);
if (input[i] == '\n') {
input[i + 1] = '\0';
break;
}
}
for (int i = 0; i < 50; i++) {
temp[i] = (int)input[i];
if (input[i + 1] == '\0')
break;
temp[i] += n;
printf("%c", (char)temp[i]);
}
return 0;
}
by rzh123 @ 2021-07-22 08:39:25
hack:
20
xyz
by rzh123 @ 2021-07-22 08:40:57
还有,这题是在 Windows
下生成的数据,在 Linux
下评测,换行符有两个,是\r\n
。
by zJx_Lm @ 2021-07-22 08:45:22
#include <bits/stdc++.h>
using namespace std;
char temp[55];
int main() {
int n; scanf("%d", &n);
scanf("%s",temp+1);
int len=strlen(temp+1);
for (int i=1,x;i<=len;i++) {
x=(temp[i]-'a'+1);
(x+=n)%=26;if(!x)x=26;
printf("%c",x+'a'-1);
}
}
by Frank_Ron @ 2021-07-22 16:46:28
谢谢两位大佬,但是它的WA的是too short on line1
by Frank_Ron @ 2021-07-22 16:47:12
@Frank_Ron 自己用DEVC++编译运行的时候是没问题的
by rzh123 @ 2021-07-23 11:19:43
@Frank_Ron 用洛谷IDE试试
by Frank_Ron @ 2021-07-24 16:44:56
@rzh123 谢谢,用洛谷IDE调试后已经AC了