错了,打佬求助

P1055 [NOIP2008 普及组] ISBN 号码

LichKing_Arthas @ 2024-06-13 20:04:06

#include<bits/stdc++.h>
using namespace std;
string a;
int main(){
    cin>>a;
    int s=(a[0]-'0')*1+(a[2]-'0')*2+(a[3]-'0')*3+(a[4]-'0')*4+(a[6]-'0')*5+(a[7]-'0')*6+(a[8]-'0')*7+(a[9]-'0')*8+(a[10]-'0')*9;
    s%=11;
    if(s==a[12]-'0')  printf("Right");
    else{
        if(s==10)  a[12]='X';
        else  a[12]=s+'0';
        cout<<a;
    }return 0;
}

by WXX532 @ 2024-06-18 21:47:27

#include<bits/stdc++.h>
using namespace std;
string a;
int main(){
    cin>>a;
    if(a[12]=='X')a[12]='9'+1;
    int s=(a[0]-'0')*1+(a[2]-'0')*2+(a[3]-'0')*3+(a[4]-'0')*4+(a[6]-'0')*5+(a[7]-'0')*6+(a[8]-'0')*7+(a[9]-'0')*8+(a[10]-'0')*9;
    s%=11;
    if(s==a[12]-'0')  printf("Right");
    else{
        if(s==10)  a[12]='X';
        else  a[12]=s+'0';
        cout<<a;
    }return 0;
}

|