50分啊,样例全过,急!!

P1055 [NOIP2008 普及组] ISBN 号码

Fengxuyang @ 2023-10-28 23:14:05

咋回事?

#include<iostream>
#include<algorithm>
using namespace std;
char a1[10];
int a[10];
int main()
{
    int sum = 0;
    char q, q1;
    scanf("%c-%c%c%c-%c%c%c%c%c-%c", &a1[1], &a1[2], &a1[3], &a1[4], &a1[5], &a1[6], &a1[7], &a1[8], &a1[9], &q);
    for (int i = 1; i <= 9; i++)
    {
        a[i] = a1[i] - '0';
        sum += a[i] * i;
    }
    sum %= 11;
    if (sum == 0) q1 = 'X';
    else q1 = sum + '0';
    if (q1 == q) cout << "Right";
    else printf("%d-%d%d%d-%d%d%d%d%d-%c", a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], q1);
    return 0;
}

by OIerGuo @ 2023-10-28 23:30:32

没开 long long


by qinjinnan @ 2023-10-28 23:32:16

第十七行,判断条件应该是sum == 10


by qinjinnan @ 2023-10-28 23:35:41

sum = 0的时候q1就是'0'

sum = 10的时候q1才是'X'


by Fengxuyang @ 2023-10-29 21:10:35

谢谢


by Fengxuyang @ 2023-10-29 21:14:42

@qinjinnan 谢谢大佬


|