Kyleshao @ 2023-06-28 14:41:25
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
cin>>s;
long long mul=0;
int cur=0;
for (int i=0;i<s.size();i++)
{
if (!(s[i]=='-'))
{
int p=s[i]-'0';
cur++;
mul+=(p*cur);
}
}
if (mul%11==(s[s.size()-1]-'0') && mul%11!=10)
{
cout<<"Right"<<endl;
}
else if (mul%11==10 && s[s.size()-1]=='X')
{
cout<<"Right"<<endl;
}
else
{
s[s.size()-1]=mul%11+'0';
if (s[s.size()-1]==':')
{
s[s.size()-1]='X';
}
cout<<s<<endl;
}
return 0;
}
by zwyyy @ 2023-06-28 19:20:04
@Kyleshao 你是不是没考虑最后一位为X的情况
by d13599385212 @ 2023-07-03 14:53:02
#include<iostream>
using namespace std;
int main(){
char a1,a2,a3,a4,a5,a6,a7,a8,a9,a10;
int t,x;
scanf("%c-%c%c%c-%c%c%c%c%c-%c",&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10);
t=(a1-48)*1+(a2-48)*2+(a3-48)*3+(a4-48)*4+(a5-48)*5+(a6-48)*6+(a7-48)*7+(a8-48)*8+(a9-48)*9;
x=t%11;
if(x!=10)
{if(x==a10-48) printf("Right");
else printf("%c-%c%c%c-%c%c%c%c%c-%c",a1,a2,a3,a4,a5,a6,a7,a8,a9,x+48);
}
if(x==10)
{if(a10=='X') printf("Right");
else printf("%c-%c%c%c-%c%c%c%c%c-X",a1,a2,a3,a4,a5,a6,a7,a8,a9);
}
return 0;
}