70pts求调

P1055 [NOIP2008 普及组] ISBN 号码

cao_20115 @ 2024-05-02 17:15:40

Code

#include <cstdio>
char a[10086];
int tmp, cnt = 1;
char c;
int main(){
    scanf("%s", a);
    for (int i = 0; i < 12; ++i) {
        if (a[i] <= '9' && a[i] >= '0') {
            tmp += (a[i] - '0') * cnt;
            cnt++;
        }
    }
    tmp %= 11;
    if (tmp < 10) c = tmp + '0';
    else c = 'X';
    if (a[13] == c) printf("Right");
    else {
        for (int i = 0; i < 12; ++i) {
            printf("%c", a[i]);
        }
        printf("%c", c);
    }
    return 0;
}

by L_zaa_L @ 2024-05-02 17:19:21

@cao_20115 if (a[13] == c) printf("Right"); 改成if (a[12] == c) printf("Right");


by cao_20115 @ 2024-05-02 17:21:27

@zaa 谢谢


by cao_20115 @ 2024-05-02 17:22:31

@zaa 已AC


|