wangchunyuIO @ 2025-01-02 12:03:39
#include<bits/stdc++.h>
using namespace std;
char a[14],c;
int l=0,k=0;
int main(){
cin>>a;
for(int i=0;i<12;i++){
if(a[i]!='-'){
k++;
l+=(a[i]-'0')*k;
}
}
l%=11;
if(l==10&&(a[12]-'0')==10){
cout<<"Right"<<endl;
}
if(l==10&&(a[12]-'0')!=10){
c='X';
a[12]=c;
cout<<a<<endl;
}
if(l!=10&&l==(a[12]-'0')){
cout<<"Right"<<endl;
}
if(l!=10&&l!=(a[12]-'0')){
a[12]=(l+'0');
a[13]='\0';
cout<<a<<endl;
}
return 0;
}
by b__b @ 2025-01-02 12:31:08
在第14行和第17行有所改动
#include<bits/stdc++.h>
using namespace std;
char a[14],c;
int l=0,k=0;
int main(){
cin>>a;
for(int i=0;i<12;i++){
if(a[i]!='-'){
k++;
l+=(a[i]-'0')*k;
}
}
l%=11;
if(l==10&&a[12]=='X'){
cout<<"Right"<<endl;
}
if(l==10&&a[12]!='X'){
c='X';
a[12]=c;
cout<<a<<endl;
}
if(l!=10&&l==(a[12]-'0')){
cout<<"Right"<<endl;
}
if(l!=10&&l!=(a[12]-'0')){
a[12]=(l+'0');
a[13]='\0';
cout<<a<<endl;
}
return 0;
}
by b__b @ 2025-01-02 12:46:03
@wangchunyuIO