HeyuNas @ 2024-03-06 18:34:36
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int k=0,sum = 0;
char s[13];
for (int i = 0; i < 13; i++)
{
cin >> s[i];
if (i != 1 && i != 5 && i != 11&&i!=12)
{
sum += k * (s[i]-48);
k++;
}
}
int index = sum % 11;
if (index == 10 && s[12] == 'X')
cout << "Right";
if (index == (s[12]-48))
cout << "Right";
else
{
s[12] = index;
printf("%s", s);
}
return 0;
}
by tegethim @ 2024-03-06 19:18:20
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,f,g,h,i,j;
char x,y,z,s;
scanf("%1d%c%1d%1d%1d%c%1d%1d%1d%1d%1d%c%c",&a,&x,&b,&c,&d,&y,&e,&f,&g,&h,&i,&z,&s);
if(s=='X') j=10;
else j=s-'0';
int sum=a+2*b+c*3+d*4+e*5+f*6+g*7+h*8+i*9;
int result=sum%11;
if(result==j) cout<<"Right";
else if(result==10) cout<<a<<x<<b<<c<<d<<y<<e<<f<<g<<h<<i<<z<<'X';
else cout<<a<<x<<b<<c<<d<<y<<e<<f<<g<<h<<i<<z<<result;
return 0;
}
那既然字符串过不了,数字代替好啦