听取WA声一片

P1914 小书童——凯撒密码

chenzhongmugu @ 2024-08-01 14:36:40


by Sky_Line @ 2024-08-01 14:38:15


by AC_Eric @ 2024-08-01 14:50:54

???


by haimingbei @ 2024-08-01 14:56:30

@chenzhongmugu

(AC,求关注)

#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    int n;
    cin>>n;
    cin>>a;
    int len=a.size();
    for(int i=0;i<len;i++){
        if(a[i]>='a'&&a[i]<='z'){
            if(a[i]+n<='z')a[i]+=n;
            else a[i]=a[i]+n-'z'+'a'-1;
        }
    }
    cout<<a;
    return 0;
}

by chenzhongmugu @ 2024-08-01 21:53:17

厉害!


by yangzijin @ 2024-08-25 22:54:40

@chenzhongmugu (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;
}

|