文章
28
粉丝
0
获赞
98
访问
3.6k
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int n=9;
int total=0;
total=(s[0]-'0')*1+(s[2]-'0')*2+(s[3]-'0')*3+(s[4]-'0')*4+(s[6]-'0')*5+(s[7]-'0')*6+(s[8]-'0')*7+(s[9]-'0')*8+(s[10]-'0')*9;
if(total%11==(s[12]-'0')||(total%11==10 && s[12]=='X')){ //注意刚开始给的ISBN编码最后一位可能为X.
cout<<"Right";
return 0;
}
//}else
//{
//for(int i=0;i<9;i++){
//total=init;
//total=total-(s[10]-'0')*9+i*9;
//if(total%11==(s[12]-'0'))
//{
// char ch=i+'0'; //i+'0'从整型变为字符型;-的话则相反;
// s[10]=ch;
// cout<<s;
// return 0;
//}
//}读懂题目很重要!!!!!!不能自己绕自己。!!!!
//}上述注释部分为刚开始理解错误,以为要进行的ISBN是要从前面的数字进行更改,而不是校验位。
if(total%11==10)
{
s[12]='X';
cout<<s;
}else{
int i=total%11;
char ch=i+'0';
s[12]=ch;
cout<<s;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发