z7k123 @ 2024-04-05 20:51:19
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
string pas;
cin >> n >> pas;
string pas1 = "abcdefghijklmnopqrstuvwsyz";
for(int i=0; i<pas.size(); ++i){
if(pas[i]+n <= 122){
char t = pas[i]+n;
cout << t;
}else{
int res = (pas[i]+n) % 123;
char t1 = pas1[res];
cout << t1;
}
}
return 0;
}
系统提示报错为这个 26 qwertyuiopasdfghjklzxcvbnm 输出为:qwertyuiopasdfghjklzxcvbnm 我测试输出为 qwertyuiopasdfghjklzxcvbnm 有点疑惑
by yangzijin @ 2024-08-25 22:58:20
你确定有试过??
by yangzijin @ 2024-08-25 22:59:40
@z7k123 AC代码
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
int n;
cin>>n;
cin>>s;
for(int i=0;i<s.size();i++){
s[i]==int(s[i]-'a'+n)%26+'a';
}
cout<<s;
return 0;
}
@z7k123 只求关!!