daishuohua @ 2024-08-30 13:35:34
又是我来求助了,样例过了,为什么40,dalao们快来帮帮忙,AC闭关
#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int main(){
cin>>n>>s;
for(int i=0;i<s.size();i++){
if(s[i]>='a' && s[i]<='z'){
cout<<char((s[i]-96+n)%26+96);
}else if(s[i]>='A' && s[i]<='Z'){
cout<<char((s[i]-64+n)%26+64);
}
}
return 0;
}
在线等,很很很急!!!
by New__bee @ 2024-08-30 13:39:39
@daishuohua 楼主 是小写字母
by Dark__dead @ 2024-08-30 13:43:15
当 s[i]
为 z ,n
为 1 时,你输出的是 `
by daishuohua @ 2024-08-30 13:43:56
刚刚没看到,但是还是没过,样例能过 @intqwe123
#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int main(){
cin>>n>>s;
for(int i=0;i<s.size();i++){
cout<<char((s[i]-96+n)%26+96);
}
return 0;
}
by Dark__dead @ 2024-08-30 13:44:09
所以要`cout<<char((s[i]-96+n-1)%26+97);
by tangyifeng123456 @ 2024-08-30 13:44:23
@daishuohua 是小写字母
by Dark__dead @ 2024-08-30 13:44:26
所以要cout<<char((s[i]-96+n-1)%26+97);
by New__bee @ 2024-08-30 13:44:44
试试:
26
z
by Dark__dead @ 2024-08-30 13:45:09
@daishuohua
by hyl_____ @ 2024-08-30 13:46:57
@daishuohua @daishuohua @daishuohua
by hyl_____ @ 2024-08-30 13:47:24
看我小号的回复 @Dark__dead