Oscar111111 @ 2024-07-01 19:37:25
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int sum=0,x=1,c;
for(int i=0;i<=10;i++){
if(s[i]>='0'&&s[i]<='9'){
sum+=(s[i]-'0')*x;
x++;
}
}
c=sum%11;
if(c==s[12]-'0') cout<<"Right";
if(c!=s[12]-'0'){
for(int i=0;i<=11;i++) cout<<s[i];
if(c!=10) cout<<c;
else cout<<"X";
}
return 0;
}
哪错了???
by Beacon_wolf @ 2024-07-01 22:49:13
@Oscar111111
少了对 X
的特判。
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int sum=0,x=1,c;
for(int i=0;i<=10;i++){
if(s[i]>='0'&&s[i]<='9'){
sum+=(s[i]-'0')*x;
x++;
}
}
c=sum%11;
if((c==s[12]-'0'&&c!=10)||(c==10&&s[12]=='X')) cout<<"Right";
else{
for(int i=0;i<=11;i++) cout<<s[i];
if(c!=10) cout<<c;
else cout<<"X";
}
return 0;
}
by Oscar111111 @ 2024-07-02 13:06:07
thank you
by Oscar111111 @ 2024-07-02 13:09:30
AC了