80分,求助,4,7错了,不知道哪里出现问题

P1055 [NOIP2008 普及组] ISBN 号码

wsqgh @ 2023-01-06 14:40:58

#include<cstdio>
using namespace std;

int main()
{
    char a,b,c,d,e,f,g,h,i,j;
    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(check=='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;
}   

by ZQIN_P @ 2023-01-06 14:42:48

@wsqgh 这边看到错误原因是误判为错...


by ZQIN_P @ 2023-01-06 14:43:55

@wsqgh if(check=='X'&&check==10 || check==j-'0')这条件有点问题吧?


by ZQIN_P @ 2023-01-06 14:44:16

改成if(j=='X'&&check==10 || check==j-'0')


|