题解 | ISBN号码
ISBN号码
https://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5
#include <stdio.h>
int main() {
int a,b,c;
char d;
scanf("%d-%d-%d-%c",&a,&b,&c,&d);
int judge =(int) (a + (b/100)*2 +((b/10)%10)*3+(b%10)*4+(c/10000)*5+((c/1000)%10)*6+((c/100) %10)*7+((c%100)/10)*8+(c%10)*9)%11;
if(judge==10)
{
if(d == 'X') printf("Right");
else printf("%d-%d-%d-X",a,b,c);
}
else
{
if(d == 'X')
{
printf("%d-%d-%d-%d",a,b,c,judge);
}
else
{
if(judge ==d-'0') printf("Right");
else printf("%d-%d-%d-%d",a,b,c,judge);
}
}
/*if(judge % 11 ==d)
{
printf("Right");
}
else
{
d=judge % 11;
printf("%d-%d-%d-%d",a,b,c,d);
}*/
return 0;
}