三四wa,谁能看一看??

P1914 小书童——凯撒密码

JackHu0117 @ 2022-03-24 09:26:17

#include<iostream>
#include<cstdio>
#include<cstring>
#include<math.h>
using namespace std;
char a[100];
int k=0;
int main(){
    cin>>k;
    scanf("%s",a);
    for(int i=0;i<strlen(a);i++){
        a[i]+=k;
    }
    cout<<a<<endl;
    return 0;
}

by 昒昕 @ 2022-03-24 09:49:57

@JackHu0117 需要取模的,比如 k=3a 就要从 z \rightarrow c


by 昒昕 @ 2022-03-24 09:50:47

还有可以看题解区 https://www.luogu.com.cn/problem/solution/P1914


by JackHu0117 @ 2022-03-24 09:51:50

@昒昕 感谢感谢,忘了这茬了


|