求助 80分 #2#10 WA

P1055 [NOIP2008 普及组] ISBN 号码

guoyibo @ 2023-09-05 23:23:06

 #include<iostream>

using namespace std;

int main(){
    char user[13] = {0};
    for(int i=0;i<13;i++){
        cin>>user[i];
    }
    int arr[10] = {0};
    for(int i=0,j=0;i<13;i++){
        if(i != 1 and i != 5 and i != 11){
            arr[j] = user[i] - '0';
            j++;
        }
    } 
    int ans = 0;
    for(int i=1;i<=9;i++){
        ans += arr[i-1] * i;
    }
    if(arr[9] == 'X' - '0'){
        if(ans%11 == 10){
            cout<<"Right";
        }
    }
    else if(ans%11 == arr[9]){
        cout<<"Right";
    }
    else{
        for(int i=0;i<12;i++){
            cout<<user[i];
        }
        if(ans%11 != 10){
            cout<<ans%11;
        }
        else{
            cout<<"X";
        }
    }
    return 0;
}

感谢大佬~


by shengj @ 2023-09-19 18:14:38

判X时一个"-"少了


|