啥?

P1914 小书童——凯撒密码

MCsky @ 2024-07-30 15:03:52


#include <iostream>
#include <cstring>
using namespace std;
int main(){
    char b[51],a[51];
    int n;
    cin>>n>>b;
    for(int i=0;i<strlen(b);i++){
        for(int j=1;j<=n;j++){
            b[i]++;
            if(b[i]>'z'){
                b[i]=='a';
            }
        }
        a[i]=b[i];
    }
    cout<<a;
    return 0;
}

by Mr_Terminator @ 2024-07-30 15:05:31

@xuyihuangmohan

if(b[i]>'z'){
    b[i]=='a';
}

睁大你的眼睛看看是不是多了点啥


by hjz_0821_ @ 2024-07-30 15:06:53

《在赋值时用“==”》


by MCsky @ 2024-07-30 15:07:02

@Mr_Terminator 多了啥?


by liuxuanming_awa @ 2024-07-30 15:07:32

6


by MCsky @ 2024-07-30 15:08:11


#include <iostream>
#include <cstring>
using namespace std;
int main(){
    char b[51],a[51];
    int n;
    cin>>n>>b;
    for(int i=0;i<strlen(b);i++){
        for(int j=1;j<=n;j++){
            b[i]++;
            if(b[i]>'z'){
                b[i]='a';
            }
        }
        a[i]=b[i];
    }
    cout<<a;
    return 0;
}

by MCsky @ 2024-07-30 15:10:39

谢大佬 @hjz_0821 @Mr_Terminator


|