很水的模拟题
要点:判断结果是X的情况,字符转数字
不多说,直接上代码
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 1000000000
string str;
int ans;
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> str;
//字符转数字:字符 - '0'
ans = ((str[0] - '0') + (str[2] - '0') * 2 + (str[3] - '0') * 3 + (str[4] - '0') * 4 + (str[6] - '0') * 5 + (str[7] - '0') * 6 + (str[8] - '0') * 7 + (str[9] - '0') * 8 + (str[10] - '0') * 9) % 11;
if (ans == str[12] - '0') cout << "Right";
else if (ans == 10 && str[12] == 'X') cout << "Right"; //特判最后一位是10的情况
else
{
for (int i = 0 ; i <= 11 ; i++) cout << str[i];
if (ans != 10) cout << ans; //特判余数为10的情况
else cout << "X";
}
return 0;
}
422

被折叠的 条评论
为什么被折叠?



