abcabccc @ 2022-02-11 16:12:22
#include <bits/stdc++.h>
using namespace std;
int main(){
char a[20];
cin>>a;
//输入
int sum=0;
for(int j=0;j<13;j++){
if(j==0){
sum+=(a[j]-48)*1;
//cout<<j<<" "<<a[j]<<endl;
} else if(j>1&&j<5){
sum+=((a[j]-48)*j);
//cout<<j<<" "<<a[j]<<endl;
}else if(j>5&&j<11){
sum+=((a[j]-48)*(j-1));
//cout<<j<<" "<<a[j]<<endl;
}
}
int t=sum%11;
//cout<<a[12];
if(t==a[12]){
cout<<"Right";
}else{
if(t==10){a[12]='X';}else
a[12]=t;
cout<<a;
}
}
by abcabccc @ 2022-02-11 16:18:51
现在50分...
#include <bits/stdc++.h>
using namespace std;
int main(){
char a[20];
cin>>a;
//输入
int sum=0;
for(int j=0;j<13;j++){
if(j==0){
sum+=(a[j]-48)*1;
//cout<<j<<" "<<a[j]<<endl;
} else if(j>1&&j<5){
sum+=((a[j]-48)*j);
//cout<<j<<" "<<a[j]<<endl;
}else if(j>5&&j<11){
sum+=((a[j]-48)*(j-1));
//cout<<j<<" "<<a[j]<<endl;
}
}
int t=sum%11;
int t2=0;
//cout<<a[12];
if(a[12]=='X'){
t2=10;
}else{
t2=a[12];
}
if(t==t2){
cout<<"Right";
}else{
if(t==10){a[12]='X';}else
a[12]=t;
cout<<a;
}
}
by 编码落寞 @ 2022-02-11 16:21:42
@abcabccc
t==a[12] 这里数字跟字符相比错误,应为t==a[12]-48.
a[12]=t;这里赋值也有问题,改为a[12]=t+48;
by abcabccc @ 2022-02-12 12:47:21
@编码落寞 原来是这里出问题了,谢谢大佬