题解 | #[NOIP2008]ISBN号码#
[NOIP2008]ISBN号码
https://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5
#include <stdio.h> int sum = 0; int j = 1; int main() { char arr[13] = { 0 }; scanf("%s", arr); for (int i = 0; i < sizeof(arr) / sizeof(arr[0]) - 1; i++) { if (i == 1 || i == 5 || i == 11) { continue; } sum += ((arr[i] - '0') * j); j++; } if (sum % 11 == arr[12]-'0' || sum % 11 == 10 && arr[12] == 'X') { printf("Right"); } else { if(sum%11 == 10) arr[12] = 'X'; else arr[12] = sum % 11 + '0'; for (int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++) { printf("%c", arr[i] ); } } }