冬笙夏洛_ @ 2021-08-22 00:34:32
第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;
}
by 夏米亚丁 @ 2021-08-22 00:40:34
保存输出保存的是你自己的输出吧
by wzmzmhk @ 2021-08-22 00:40:46
@冬笙夏洛_ 建议到洛谷IDE上试试结果
by wzmzmhk @ 2021-08-22 00:45:47
@冬笙夏洛_ #4中你的程序在洛谷IDE上输出的结果为6-670-82162-XX
,显然不对
by 冬笙夏洛_ @ 2021-08-22 09:32:16
@wzmzmhk 刚刚试了,是Right 。
by 冬笙夏洛_ @ 2021-08-22 09:34:15
@夏米亚丁 不是用那个保存输入输出的话,那在哪里看样例和答案呀?
by cuijingyi1111 @ 2021-08-28 09:26:56
暴力