为什么40?

P1914 小书童——凯撒密码

wangjingtian1 @ 2023-07-12 15:21:55

这是代码

include <iostream>```

include <cstring>

using namespace std; int main(){ int n; cin>>n; char j[n]; cin>>j; char w[n]; for(int i=0;i<strlen(w);i++){ if(j[i]!='z'){ w[i]=j[i]+n; }else{ w[i]='a'; }

 }
 cout<<w;

}


by wangjingtian1 @ 2023-07-12 15:22:54

?

include <iostream>``` include <cstring> using namespace std; int main(){ int n; cin>>n; char j[n]; cin>>j; char w[n]; for(int i=0;i<strlen(w);i++){ if(j[i]!='z'){ w[i]=j[i]+n; }else{ w[i]='a'; }

} cout<<w; }


by ccg12345 @ 2023-07-12 15:26:25

希望更丰富的展现?使用 Markdown、LaTeX 公式。


by wangjingtian1 @ 2023-07-12 15:29:55

sss

include <iostream>``` include <cstring> using namespace std; int main(){ int n; cin>>n; char j[n]; cin>>j; char w[n]; for(int i=0;i<strlen(w);i++){ if(j[i]!='z'){ w[i]=j[i]+n; }else{ w[i]='a'; }

} cout<<w; }```


by Billy_Zhang @ 2023-08-14 20:39:37

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    int n;
    cin>>n>>s;
    for(int i=0;i<=s.size()-1;i++){
        if(s[i]+n>'z'){
            s[i]=char(int((s[i]+n-'a')%26))+'a';
            continue;
        }
        s[i]+=n;
    }
    cout<<s;
    return 0;
}
AC代码

问题较多,自己比对吧!!! 不客气!


|