求助,为什么只有50分

P1055 [NOIP2008 普及组] ISBN 号码

jd123 @ 2022-10-03 11:33:34


int main()
{
    int a[11]={0};
    scanf("%d-%d-%d-%d",&a[1],&a[2],&a[5],&a[10]);
    int sum=0,b,c=10000,d=a[5];
    b=a[2]/10;
    a[3]=b%10;
    a[4]=a[2]%10;
    a[2]=a[2]/100;
    for(int j=5;j<=9;j++)
    {   
        a[j]=d/c;
        d%=c;
        c/=10;

    }
    for(int i=1;i<=9;i++)
    {
        sum+=a[i]*i;
    }
    a[0]=sum%11;
    if(a[0]==a[10]){
        printf("Right");

    }else printf("%d-%d%d%d-%d%d%d%d%d-%d",a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[0]);
    return 0;

}

by No1_TLEman @ 2022-10-03 12:23:24

#include<cstdio>  
using namespace std;
char a, b, c, d, e, f, g, h, i, j;
int main(){
    int check;
    scanf("%c-%c%c%c-%c%c%c%c%c-%c",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
    check = (a-'0')*1 + (b-'0')*2 + (c-'0')*3 + (d-'0')*4 + (e-'0')*5 + (f-'0')*6 + (g-'0')*7 + (h-'0')*8 + (i-'0')*9;
    check %= 11;
    if(j=='X'&&check==10||check==j-'0')
    printf("Right\n");
    else{
    printf("%c-%c%c%c-%c%c%c%c%c-%c",a,b,c,d,e,f,g,h,i,check==10?'X':check+'0');
    return 0;

不要定数组, } }


|