Refrain520CC @ 2022-12-26 18:12:00
#include<stdio.h>
int main()
{
char str[14] = { 0 };
int x;
gets(str);
x = ((str[0] - '0') * 1 + (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 ((x == 10 && str[12] == 'X') || (x != 10 && str[12] - '0' == x))
printf("Right");
else if (x == 10)
{
str[12] = 'X';
puts(str);
}
else if (x != 10)
{
str[12] = (char)(x + '0');
puts(str);
}
return 0;
}
测试点8是啥玩意,一直不过,求助一下大佬们
by Creative_sad_yosgic @ 2022-12-26 18:30:59
不要用gets(恼
by gjgjfjjg @ 2022-12-29 08:50:34
编译器用C++11,C++20有几个测试点过不了
#include<bits/stdc++.h>
using namespace std;
int main() {
char a[13];
unsigned int b;
cin>>a;
b=((a[0]-'0')+(a[2]-'0')*2+(a[3]-'0')*3+(a[4]-'0')*4+(a[6]-'0')*5+(a[7]-'0')*6+(a[8]-'0')*7+(a[9]-'0')*8+(a[10]-'0')*9)%11;
if(b==a[12]-'0'||(a[12]=='X'&&b==10))
cout<<"Right";
else {
cout<<a[0]<<a[1]<<a[2]<<a[3]<<a[4]<<a[5]<<a[6]<<a[7]<<a[8]<<a[9]<<a[10]<<a[11];
if(b==10)
cout<<'X';
else
cout<<b;
}
return 0;
}