CUFT @ 2018-12-26 13:42:09
#include<iostream>
#include<cstdio>
using namespace std;
char letter[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main(){
char c=0;
int n;
cin>>n;
c=getchar();
c=getchar();
while(c!=10){
cout<<letter[(c-'a'+n)%26];
c=getchar();
}
return 0;
}
by CUFT @ 2018-12-26 13:48:10
在本地跑完全没问题,用文件输出也一样。
by Victorique_De_Blois @ 2018-12-26 13:50:24
IDE试一下。
by BCZSX @ 2018-12-26 13:51:29
你问什么不用数组@CUFT
by _SeeleVollerei_ @ 2018-12-26 13:57:15
#include<cstdio>
int main()
{
char in[100];
int n, j;
scanf("%d%s", &n, in);
for(j = 0; in[j] != '\0'; j++)
putchar((in[j]-'a'+n)%26+'a');
}
@CUFT
by CUFT @ 2018-12-27 13:28:15
@BCZSX 字符一个一个处理不可以吗?
by CUFT @ 2018-12-27 13:29:30
@淼淼大侠 谢谢。所以说这道题是必须用字符串来做而不能一个字符一个字符地处理吗?
by _SeeleVollerei_ @ 2018-12-27 13:46:55
@CUFT 把while(c!=10)改成while(c!='\n')会好点,