求助大佬60分!

P1914 小书童——凯撒密码

aizehao123 @ 2022-05-01 10:14:14


#include<bits/stdc++.h>
using namespace std;
char a[100];
int n,len;
int main(){
    cin>>n>>a;
    len=strlen(a);
    for(int i=0; i<=len-1;i++){
        if(a[i]=='z'&&n!=0) {
            a[i]='a'-1;
        }else if(a[i]=='z'&&n==0){
            a[i]='z';
        } 
        a[i]+=n%26;
        cout<<a[i];
    }
    return 0;
}```

by MrCR7 @ 2022-05-01 10:21:35

@aizehao123 头像赞


by JustinXiaoJunyang @ 2022-05-01 10:32:06

@aizehao123 求关注~

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s;
    int n;
    cin >> n;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (s[i] >= 'z')
            {
                s[i] = 'a';
            }
            else
            {
                s[i]++;
            }
        }
    }
    cout << s << endl;
    return 0;
}

by liusiqi1234 @ 2022-05-01 11:33:55

?


by liusiqi1234 @ 2022-05-01 11:44:47

#include<bits/stdc++.h>
using namespace std;
char ch[55];
int len,n;
int main(){
    cin>>n>>ch;
    len=strlen(ch);
    for(int i=0;i<=len-1;i++){
        for(int j=1;j<=n;j++){
            if(ch[i]=='z'){
                ch[i]='a';
                continue;
            }
            ch[i]++; 
        }
        cout<<ch[i];
    }
    return 0;
}

by liusiqi1234 @ 2022-05-01 11:45:21

满分代码


by aizehao123 @ 2022-05-05 20:44:20

@JustinXiaoJunyang 关注了


by xhx2011 @ 2022-08-26 21:49:47

aizehao写的很标准


|