60分求助

P1914 小书童——凯撒密码

Lvyuze @ 2021-08-19 18:55:12

#include<iostream>
#include<cstring>
using namespace std;
int n,m;
string a,x[100],l;
int main()
{
cin>>n>>a;
for(int i=0;i<a.size();i++){
    m=int(a[i])+int(n); 
    if(m==123) l="a";
    else if(m==124) l="b";
    else if(m==125) l="c";
    else l=int(a[i])+n;
    x[i]=l;
}
for(int i=0;i<a.size();i++) cout<<x[i];
return 0;
}

by jyb666 @ 2021-08-19 19:03:09

@Lvyuze n可以更大的啊,可以用取模来做


by Lvyuze @ 2021-08-19 19:04:56

@jyb666 ?


by jyb666 @ 2021-08-19 19:05:07

@Lvyuze hack数据 http://1.116.217.97/ide/judge.php?id=wBLgpbUto3


by jyb666 @ 2021-08-19 19:06:07

@Lvyuze 当 n>3 字符串里有x,y,z你的程序就挂了


by Lvyuze @ 2021-08-19 19:06:38

@jyb666 对啊,我下载数据就。。。


by Lvyuze @ 2021-08-19 19:07:21

@jyb666 那怎么做啊


by jyb666 @ 2021-08-19 19:12:21

@Lvyuze http://1.116.217.97/ide/judge.php?id=whusY2Qw1k


by Lvyuze @ 2021-08-19 19:15:58

@jyb666 过了,谢谢大佬


|