python #4上面WA IDE结果正确 提交却说一行一列是6

P1055 [NOIP2008 普及组] ISBN 号码

Victor0128 @ 2022-03-09 19:30:58

a = input().split('-')

b = int(a[0] + a[1] + a[2])

i = 0 s = {} sum = 0 for i in range(9): s[i] = (b//(10*(8-i))) % 10 s[i] = s[i] (i + 1) sum = sum_ + s[i]

c = int(sum_ % 11)

if (c == 10): ID = 'X' else: ID = str(c)

if (ID == a[3]): print('Right') else: print(a[0] + '-' + a[1] + '-' + a[2] + '-' + ID)


by farmer_snack @ 2022-03-09 19:47:24

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

|