qianhy_cool @ 2024-09-24 06:30:11
#include <iostream>
using namespace std;
int main() {
int num1, num2, num3;
char c, a;
cin >> num1 >> c >> num2 >> c >> num3 >> c >> a;
int sum = (num1 + num2 / 100 * 2 + num2 / 10 % 10 * 3 + num2 % 10 * 4 + num3 / 10000 * 5 + num3 / 1000 % 10 * 6 + num3 / 100 % 10 * 7 + num3 / 10 % 10 * 8 + num3 % 10 * 9) % 11;
if (char(sum) == a)
cout << "Right";
else if (sum == 10 && a == 'X')
cout << "Right";
else {
if (sum != 10) {
cout << num1 << "-" << num2 << "-" << num3 << "-" << sum;
} else {
cout << num1 << "-" << num2 << "-" << num3 << "-X";
}
}
}
by Super_Cube @ 2024-09-24 09:09:51
@qianhy_cool 改好了。
#include <iostream>
using namespace std;
int main() {
int num1, num2, num3;
char c, a;
cin >> num1 >> c >> num2 >> c >> num3 >> c >> a;
int sum = (num1 + num2 / 100 * 2 + num2 / 10 % 10 * 3 + num2 % 10 * 4 + num3 / 10000 * 5 + num3 / 1000 % 10 * 6 + num3 / 100 % 10 * 7 + num3 / 10 % 10 * 8 + num3 % 10 * 9) % 11;
if (sum<10&&sum==a-48)
cout << "Right";
else if (sum == 10 && a == 'X')
cout << "Right";
else {
if (sum != 10) {
cout << num1 << "-" << num2 << "-" << num3 << "-" << sum;
} else {
cout << num1 << "-" << num2 << "-" << num3 << "-X";
}
}
}
by qianhy_cool @ 2024-09-24 20:45:56
@Super_Cube 谢谢大佬的帮助