第4和8有问题,,
第4个例子我输出的是Right,答案也是Right,,居然是WA???
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
string str;
getline(cin, str);
int a[10];
a[1] = str[0];
a[2] = str[2];
a[3] = str[3];
a[4] = str[4];
a[5] = str[6];
a[6] = str[7];
a[7] = str[8];
a[8] = str[9];
a[9] = str[10];
int res = 0;
for (int i = 1; i <= 9; ++i) {
res += i * (a[i] - '0');
res %= 11;
}
int n = str.size() - 1;
if (res == 10) {
if (str[n] == 'X')cout << "Right" << endl;
else {
str[n] = 'X'; cout << str << endl;
}
}
else if(res == str[n]-'0')cout << "Right" << endl;
else {
str[n] = res + '0';
cout << str << endl;
}
return 0;
}