题解 | #[NOIP2008]ISBN号码#
[NOIP2008]ISBN号码
https://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5
#include <iostream>
using namespace std;
int main() {
int q,w,e,m;
char r;
char ch1,ch2,ch3;
cin>>q>>ch1>>w>>ch2>>e>>ch3>>r;
if(r=='X'){
m=10;
}
else {
m=r-'0';
}
int b;
b=(q*1+(w/100)*2+(w/10%10)*3+(w%10)*4+(e/10000)*5+(e/1000%10)*6+(e/100%10)*7+(e/10%10)*8+(e%10)*9)%11;
if(b==m){
cout<<"Right"<<endl;
}
else if (b==10) {
cout<<q<<"-"<<w<<"-"<<e<<"-"<<"X"<<endl;
}
else{
cout<<q<<"-"<<w<<"-"<<e<<"-"<<b<<endl;
}
}
// 64 位输出请用 printf("%lld")
查看9道真题和解析
