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