小数据没问题,一碰到大一点的就乱码,为什么

P1914 小书童——凯撒密码

liuzeyu12a @ 2018-07-11 20:58:26

include<iostream>

include<string.h>

include<cstdio>

using namespace std;

int main()

{

char ch[50];
int array[50];
int a;
cin >> a;
cin>>ch;
int LEN = strlen(ch);
for (int i = 0; i < LEN; i++)
{
    if (ch[i] != 'z')
        array[i] = ch[i] + a;
    else
        array[i] = ch[i] - 25;
}
for (int j = 0; j < LEN; j++)
    printf("%c", array[j]);
return 0;

}


by ComeOver· @ 2018-07-12 09:42:20

@liuzeyu12a

您赋一下初值试试


|