80分,为啥

P1055 [NOIP2008 普及组] ISBN 号码

llllllllll0 @ 2024-11-04 20:20:42

#include <stdio.h>
#include <stdlib.h>

int main(){
    int a[10] = {0};
    int sum = 0,x = 0;
    for ( int i=1,j;i<10; ){
        if ( (scanf("%1d",&a[i]))==1 ){ 
        sum += a[i]*i;
        i++;
        }
    }
    scanf("%2d",&x);
    x = x>0?x:-x;
    if ( sum%11 == x ){
        printf("Right");
        return 0;
    }
    for ( int i=1;i<10;i++ ){
        printf("%d",a[i]);
        if ( i==1||i==4||i==9 ){
            printf("-");
        }
    }
    if ( sum%11==10 ){
        printf("X");
    }else{
        printf("%d",sum%11);
    }
    return 0;
} 

|