MercuryFish @ 2021-04-06 18:10:09
#include <cstdio>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
int n;
cin>>n;
getchar();
char s;
while(1){
s=getchar();
if(s == '\n'){
break;
}
s=(s-'a'+n)%26+'a';
putchar(s);
}
return 0;
}
by _caiji_ @ 2021-04-06 18:12:50
不判 \r
人
by MercuryFish @ 2021-04-06 18:35:54
@caijianhong 什么意思啊?没有看懂
by BreakPlus @ 2021-04-06 18:38:18
windows 下回车是 \r\n
所以特判以下
by MercuryFish @ 2021-04-06 20:01:43
@BreakPlus 这样吗?可是结果还是全错。
#include <cstdio>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
int n;
cin>>n;
getchar();
char s;
while(1){
s=getchar();
if(s == '\r' || s == '\n'){
break;
}
s=(s-'a'+n)%26+'a';
putchar(s);
}
return 0;
}
by Almus @ 2021-04-10 17:36:16
%%%
by Wobuxing @ 2021-04-23 20:35:14
试一下gets()