Sicily-ISBN
字符串的简单处理
要注意不要漏了第20行的判断
#include<iostream> #include<string> #include<cstring> using namespace std; int main() { string str; while(cin >> str) { int sum = 0; int m = 10; int i = 0; while(m!=1) { if (str[i] != '-') { sum += (str[i] - '0')*m; m--; } i++; } int j = 11 - sum% 11; if (j == 11) { j = 0;//这里贼坑 } if (j != 10) { cout << str << '-' << j << endl; } else { cout << str << '-' << 'X' << endl; } } return 0; }
-