题解 | #[NOIP2008]ISBN号码#
[NOIP2008]ISBN号码
https://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5
#include<stdio.h>
int main(){
int a,b,c;
char d;
int x,y,z,m,n,i,j,k,p;
scanf("%1d-%3d-%5d-%1c",&a,&b,&c,&d);
x=(b%10);
y=((b/10)%10);
z=b/100;
m=(c%10);
n=(c/10)%10;
i=(c/100)%10;
j=(c/1000)%10;
k=c/10000;
p=(a*1+(z*2)+(y*3)+(x*4)+(k*5)+(j*6)+(i*7)+(n*8)+(m*9))%11;
if(p==(d-'0')){
printf("Right\n");
}
else if (p==10){
if(d=='X'){
printf("Right\n");
}
else{
printf("%1d-%3d-%5d-X\n",a,b,c);
}
}
else{
printf("%1d-%3d-%5d-%1d\n",a,b,c,p);
}
}
int main(){
int a,b,c;
char d;
int x,y,z,m,n,i,j,k,p;
scanf("%1d-%3d-%5d-%1c",&a,&b,&c,&d);
x=(b%10);
y=((b/10)%10);
z=b/100;
m=(c%10);
n=(c/10)%10;
i=(c/100)%10;
j=(c/1000)%10;
k=c/10000;
p=(a*1+(z*2)+(y*3)+(x*4)+(k*5)+(j*6)+(i*7)+(n*8)+(m*9))%11;
if(p==(d-'0')){
printf("Right\n");
}
else if (p==10){
if(d=='X'){
printf("Right\n");
}
else{
printf("%1d-%3d-%5d-X\n",a,b,c);
}
}
else{
printf("%1d-%3d-%5d-%1d\n",a,b,c,p);
}
}