求助!!!(就是有两个WA 为什么!!!)(跪求大佬相助)))

P1055 [NOIP2008 普及组] ISBN 号码

bi_8_bo @ 2024-08-27 22:51:06

//0-670-82162-4
//0-690-82162-4
//1-690-82162-0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
    char a[13];
    int sum = 0;
    int mark = 1;

    for (int i = 0; i <= 12; i++) {
        scanf_s("%c", &a[i]);

        if (i < 11) {
            if (i == 1 || i == 5)
                continue;
            else {
                sum += mark * (a[i] - '0');
                mark++;
            }
        }

    }

    sum = sum % 11;

    if (sum == (a[12] - '0'))
        printf("Right");
    else {
        if (sum == 10) {
            a[12] = 'X';
        }
        else {
            a[12] = '0' + sum;
        }
        for (int i = 0; i <= 12; i++) {
            printf("%c", a[i]);
        }
    }
    return 0;
}

by bi_8_bo @ 2024-08-27 22:52:40

那个scanf_s不用管,_s忘删了


by beimingyun @ 2024-09-12 20:17:33

scanf_s(是vs提供的函数)


|