jiangtaooo @ 2020-03-07 20:20:06
#include<iostream>
using namespace std;
int main()
{
int n,i = 0;
char a[50],s;
cin >> n;
cin >> s;
while (s != '\n')
{
a[i] = s;
cout << char(a[i++] + n);
cin >> s;
}
}
by Dimly_dust @ 2020-03-07 20:21:10
你‘z’没特判吧
by Flash1ng @ 2020-03-07 20:22:47
#include<bits/stdc++.h>
using namespace std;
string s;
int n,i,j;
int main() {
cin>>n;
cin>>s;
for(i=0; i<s.size(); i++) {
for(j=1; j<=n; j++) {
s[i]++;
if(s[i]>'z')
s[i]='a';
}
}
cout<<s;
return 0;
}
by Dimly_dust @ 2020-03-07 20:24:03
还有,你为什么 只输一个字符啊!
by Dimly_dust @ 2020-03-07 20:25:00
@光辉的太阳 不要上代码,下次是黑题怎么办?
by Dimly_dust @ 2020-03-07 20:32:15
先输入s别先判断
by liqingyang @ 2020-03-07 20:32:35
@Dimly_dust 您说的太对了
by liqingyang @ 2020-03-07 20:33:46
但是我忍不住说:
这人代码好奇怪!请了解一下正常人的代码!
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
int key;
cin>>key>>str;
for(int i=0;i<str.size();i++)
{
cout<<char((str[i]+key-'a')%26+'a');
}
cout<<endl;
return 0;
}
by Dimly_dust @ 2020-03-07 20:36:40
行吧,你看看楼上的代码,研究一下
by jiangtaooo @ 2020-03-07 20:43:19
@光辉的太阳 谢谢你,我的原因应该是用char数组存的字符串,从而导致了RE。现在我用string没问题了。
by jiangtaooo @ 2020-03-07 20:43:35
@Dimly_dust 是呢,这个也忘了。