50,50 求大佬指点

P1055 [NOIP2008 普及组] ISBN 号码

``` 如果余数为10,则识别码为大写字母X ```
by Soledad_S @ 2018-11-26 22:13:15


@[qzh091818](/space/show?uid=122995)
by Soledad_S @ 2018-11-26 22:13:41


``` #include<iostream> using namespace std; int main(){ char a[15]; int x=0,m=0,t,b[30]; for(int i=1;i<=13;i++){ cin>>a[i]; } for(int i=1;i<=13;i++){ if(i!=2&&i!=6&&i!=12&&i!=13){ b[i]=a[i]-'0'; } if(i==13) if(a[i]=='X')b[i]=10; else b[i]=a[i]-'0'; } for(int i=1;i<=13;i++){ if(i!=2&&i!=6&&i!=12&&i!=13){ m++; x+=(b[i])*m; } } //cout<<x<<endl; //cout<<x%11<<endl; //cout<<b[13]+2<<endl; if((x%11)==(b[13])){ cout<<"Right"<<endl; } else{ b[13]=x%11; //cout<<"xxx "<<x%11<<endl; //cout<<"yyy "<<b[13]<<endl; for(int i=1;i<=13;i++){ if(i==2||i==6||i==12){ cout<<a[i]; } else if(b[i]!=10){ cout<<b[i]; } else cout<<"X"; } } return 0; } ```
by Soledad_S @ 2018-11-26 22:18:52


|