50分求助大佬们,感激不尽!!!

P1055 [NOIP2008 普及组] ISBN 号码

ZJdog @ 2024-02-23 22:08:13

#include<stdio.h>

int main(){
    int a,b,c,d;
    char e;
    scanf("%d%c%d%c%d%c%d",&a,&e,&b,&e,&c,&e,&d);

    int f[10];
    f[0] = a;
    f[1] = b/100;
    f[2] = b%100/10;
    f[3] = b%10;
    f[4] = c/10000;
    f[5] = (c-f[4]*10000)/1000;
    f[6] = (c-f[4]*10000-f[5]*1000)/100;
    f[7] = (c-f[4]*10000-f[5]*1000-f[6]*100)/10;
    f[8] = c%10;
    f[9] = d;

    int i,g=0;
    for(i=0;i<9;i++){
        g+=(f[i]*(i+1));
    }

    if(g%11==f[9]){
        printf("Right");
    }else{
        printf("%d%c%d%c%d%c%d",a,e,b,e,c,e,g%11);
    }

    return 0;
}

代码可能很低级,初学者,感谢大佬们指导


|