FireWolf @ 2021-02-28 19:53:05
#include <stdio.h>
int main(void)
{
int n;
char ch;
scanf("%d", &n);
n = n % 26;
getchar();
getchar();
while ((ch = getchar()) != '\r')
putchar((ch - 'a' + n) % 26 + 'a');
return 0;
}
by BMTXLRC @ 2021-02-28 19:54:04
运行没问题只代表没有CE,不代表TLE吧(((
by dhclient_eth1 @ 2021-02-28 19:54:50
@FireWolf TLE:超出时间限制
by Water_Cows @ 2021-02-28 19:59:40
#include <stdio.h>
int main(void)
{
int n;
char ch;
scanf("%d", &n);
n = n % 26;
getchar();
getchar();
- while ((ch = getchar()) != '\r')
putchar((ch - 'a' + n) % 26 + 'a');
+ while ((ch = getchar()) != EOF)
return 0;
}
后面可能没有字符了,以后写这种就是直接写
while(... != EOF)
或者 while(~...)
by Water_Cows @ 2021-02-28 20:00:44
就是把 while ((ch = getchar()) != '\r')
改成 while ((ch = getchar()) != EOF)
即可,强烈建议这种字符串的题用 cin
by _caiji_ @ 2021-02-28 20:01:54
@Water_Cows 我scanf(" %c",&ch)
什么时候才能站起来
by FireWolf @ 2021-02-28 20:07:21
@Water_Cows 解决了,感谢诸位大佬! @caijianhong @Thujoars @BMTXLRC
by Argon_Cube @ 2021-02-28 20:12:12
@caijianhong 站不起来
by Mine_King @ 2021-02-28 20:29:47
@caijianhong 站不起来
讲道理getchar
又比scanf
快又能实现和scanf
一样的效果这还咋站起来啊QAQ
by _caiji_ @ 2021-02-28 20:30:33
@Mine_King scanf(" %c",&ch)
能过滤空格
by ZBAA_MKC @ 2021-02-28 21:27:11
c++的getline不香么