Myosotis_alpestris @ 2022-03-23 15:36:02
RT
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
char c[100];
cin>>c;
for (int i=0;i<strlen(c);i++)
{
c[i]+=a;
if(c[i]>122)
{
c[i]-=36;
}
cout<<c[i];
}
}
by mengtian_ @ 2022-03-23 18:43:30
在代码的第9行要把a%26,结果不变,a太大会造成第3个点WA;在代码的第14行我建议你用三目运算符,详情看这 ,这样可以防止ASCLL码太大,以致出现乱码的BUG
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
a%=26;
char c[100];
cin>>c;
for (int i=0;i<strlen(c);i++)
{
char s=c[i]+a>122?c[i]+a-26:c[i]+a;
cout<<s;
}
}
by mengtian_ @ 2022-03-23 19:46:12
@satian
by Myosotis_alpestris @ 2022-03-24 18:43:46
@w13863980096 谢谢大佬