Faded_wind123 @ 2024-03-22 10:56:53
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a[50];
string s;
cin>>n;
cin>>s;
for(int i=0;i<s.length();i++){
a[i]=s[i];
a[i]+=n;
if(a[i]>127){a[i]=a[i]-26;}
s[i]=a[i];
cout<<s[i];
}
return 0;
}
by kexun_kevin @ 2024-03-26 20:17:08
if(a[i]>127){a[i]=a[i]-26;}
改为
if(a[i]>122){a[i]=a[i]-26;}
因为 'z' 的 ASCII 码是 122
by kexun_kevin @ 2024-03-26 20:17:47
@Faded_wind123
by Faded_wind123 @ 2024-03-26 20:22:59
@kexun_kevin 感谢大佬