You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
602 B

#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
cin >> str;
int sum = 0;
for (int i = 0, j = 1; i + 1 < str.size(); i++) // 最后一位是识别码,需要单独处理
if (str[i] != '-') {
sum += (str[i] - '0') * j;
j++;
}
sum %= 11;
char c = 'X';
if (sum < 10) c = '0' + sum;
if (c == str.back()) // str.back()是指最后一位的识别码
puts("Right");
else {
str.back() = c;
cout << str << endl; // 替换正确的识别码
}
return 0;
}