本地单机测试ok,样例也对,为啥全部wa了。求大佬解惑。

P1914 小书童——凯撒密码

sevenwaters @ 2019-02-22 11:10:52

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n, i;
    char a[50] = { 0 }, b[50] = { 0 };
    scanf("%d", &n);
    getchar();
    for (i = 0;i<50;i++)
    {
        a[i] = getchar();
        if (a[i] == '\n')
        {
            break;
        }
    }
    for (i = 0;i<50;i++)
    {
        if (a[i]>96 && a[i]<123)
        {
            if (a[i] + n % 26 > 122)
            {
                b[i] = a[i] + n % 26 - 'z' + 96;
            }
            else if (a[i] + n % 26 < 123)
            {
                b[i] = a[i] + n % 26;
            }       
        }
        else
        {
            b[i] = a[i];
        }
    }
    for (i = 0;i<50;i++)
    {
        if (b[i]>96 && b[i]<123)
        {
            printf("%c", b[i]);
        }
    }
    system("pause");
    return(0);
}

by sevenwaters @ 2019-02-22 11:48:38

@Daniel_WFY_923 明白,我再试一下。好累


by sevenwaters @ 2019-02-22 11:49:06

@Daniel_WFY_923 谢谢大佬能看我的代码,哈


by sevenwaters @ 2019-02-22 11:52:00

@Daniel_WFY_923 又全wa,我去冷静一下


by NaCly_Fish @ 2019-02-22 11:58:33

@Daniel_WFY_923
getchar配合while很好用的啊qwq
读到换行符什么的直接跳过去不就好啦


by NaCly_Fish @ 2019-02-22 11:59:21

@Daniel_WFY_923 而且getchar比scanf快好多


by OvOAuto @ 2019-02-22 12:18:43

@NaCly_Fish %%%


by OvOAuto @ 2019-02-22 12:22:42

@NaCly_Fish (记笔记)


by NaCly_Fish @ 2019-02-22 12:23:58

@Daniel_WFY_923 QAQ


by Lovable_Wind @ 2019-02-22 13:09:33

@sevenwaters 给a做一下.size(length),求一下长度


by Lovable_Wind @ 2019-02-22 13:10:59

没人了吗


上一页 | 下一页