C++80分

P1055 [NOIP2008 普及组] ISBN 号码

MaiJingYao666 @ 2022-10-01 11:09:19

#include<iostream>
using namespace std;
int s,k=1;
int main(){
    char a[14];
    cin>>a;
    for(int i=0;i<12;i++){
        if(a[i]=='-')continue;
        s+=(a[i]-'0')*k;
        k++;
    }
    s=s%11;
    if(s==a[12]-'0')cout<<"Right";
    else{
        if(s==10)a[12]='X';
        else a[12]='0'+s;
        printf("%s",a);
    }
    return 0;
}

by Kirei @ 2022-10-01 11:16:17

if(s==a[12]-'0')cout<<"Right";

要特判a[12]='X'


by MaiJingYao666 @ 2023-04-02 15:34:51

@Kirei 谢谢大佬


|