题解 | [NOIP2008]ISBN号码
#include <stdio.h>
#include <string.h>
int main() {
char arr[15];
int j = 1,sum = 0;
scanf("%s",arr);
int end = strlen(arr);
for (int i=0;i<end-1;i++){ //这里记得是end-1,最后的标识不能算在内
if(arr[i]!='-'){
sum += (arr[i]-'0')*j;
j++;
}
}
int y = sum%11;
char x ;
if(y == 10){
x = 'X';
}
else{
x = y + '0';
}
if(x == arr[end-1]){
printf("Right");
}
else{
arr[end-1] = x;
printf("%s\n",arr);
}
return 0;
}
