50分的代码……

P1055 [NOIP2008 普及组] ISBN 号码

Yunjin @ 2021-08-16 15:45:48

求各位大佬帮忙康康qwq

#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[15];
    int b = 1,n = 0;
    for(int i = 1;i <= 13;i++){
        cin>>a[i];
        if(a[i] >= '0' && a[i] <= '9' && i != 13){
            n+=(int)((a[i]-'0')*b);
            b++;
        }
    }
    n%=11;
    if(n == (int)(a[13]-'0')){
        cout<<"Right";
    }
    else{
        for(int i = 1;i <= 12;i++){
            cout<<a[i];
        }
        cout<<n;
    }   

    return 0;
}

by 迟暮天复明 @ 2021-08-16 16:10:02

for(int i = 1;i <= 12;i++){
  cout<<a[i];
}

这个 a 里面有 -


|