题解 | #[NOIP2008]ISBN号码#
[NOIP2008]ISBN号码
https://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5
#include <stdio.h> #include <math.h> int main() { char isbn[14] = {0}; scanf("%s", isbn); int sum = 0; int j = 1; int i = 0; for(i=0; i < 12; i++) { if(isbn[i] >= '0' && isbn[i] <= '9') { sum += (isbn[i] - '0')*(j++); } } sum %= 11;//识别码 char s = 0; if(sum != 10) { s = sum+'0'; } else { s = 'X'; } if (isbn[i] == s) { printf("Right\n"); } else { isbn[i] = s; printf("%s\n", isbn); } return 0; }