//100分,进步的是使用了isdigit()函数判断字符是不是英文字母
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
string str;
cin>>str;
int a[10];
int len,i,sum = 0,j = 0;
len = str.length();
for(i=0;i<len-1;i++){
if(isdigit(str[i])){
a[j] = str[i] - ‘0‘;
j++;
}
}
for(i=0;i<j;i++){
sum += a[i]*(i+1);
}
if(isdigit(str[len-1])){
a[9] = str[len-1] - ‘0‘;
if(sum%11 == a[9]) cout<<"Right";
else {
if(sum%11==10) {
str[len-1] = ‘X‘;
cout<<str;
}
else {
str[len-1] = sum%11+‘0‘;
cout<<str;
}
}
}
else {
if(sum%11==10) cout<<"Right";
else {
str[len-1] = sum%11+‘0‘;
cout<<str;
}
}
return 0;
}
时间: 2024-11-20 11:46:39