wumingyou @ 2024-01-24 13:07:49
RT
c++98 提交70分。 c++新版本 提交100分。
Code:
#include <bits/stdc++.h>
using namespace std;
char a[13];
int main()
{
cin >> a;
int cnt = 0, res = 0;
for (int i = 0; i < 11; i ++ ) {
if (a[i] == '-') {
continue;
}
(res += (a[i] - '0') * (++ cnt)) %= 11;
}
int t = a[12] == 'X' ? 10 : (a[12] - '0');
if (t == res) {
cout << "Right";
} else {
a[12] = res == 10 ? 'X' : (res + '0');
cout << a;
}
return 0;
}
by leiaxiwo @ 2024-01-24 13:17:02
@wumingyou g++20优化了,无所谓,你思路是对的