50分WA求助

P1055 [NOIP2008 普及组] ISBN 号码

BLX32M_10 @ 2022-02-16 11:00:48

#include <iostream>
using namespace std;
char a[15], p[12]="0123456789N";

int main()
{
    scanf("%s", a);
    int x = 0, n = 1;
    for (int i = 0; i < 12; i++)
    {
        if (a[i] == '-')
            continue;
        x += (a[i] - 48) * n;
        n++;
    }
    if (x % 11 == a[12] - 48)
        printf("Right");
    else
    {
        a[12] = x % 11 + 48;
        printf("%s", a);
    }
    return 0;
}

by RockyYue @ 2022-02-16 11:09:14

@Brooksx 最后输出时你没考虑X(%11=10)的情况


|