代码如下,只有1,4,7,过了,没过的都是最后一位输出错误。
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
int all = 0,j = 0;
cin >> str;
for (int i = 0; i <= 11; i++) {
if (str[i] != '-') {
j++;
all += int(str[i] - '0') * j;
}
}
all %= 11;
if (all == (str[12] - '0')||(all == 10 && str[12] == 'X'))
cout << "Right";
else if( all == 10)
cout << str << '\b' << 'X';
else
cout << str << '\b' << all;
return 0;
}