90分,测试点1过不去,求大佬的帮助!

P1055 [NOIP2008 普及组] ISBN 号码

zpn001 @ 2023-01-08 20:37:38

#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
// 填上你觉得需要的其他头文件
using namespace std;
char a[1300];
int c, s, b[1000],yu;
int main() {
    for (int i = 0; i < 13; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < 13; i++) {
        if (a[i] != '-') {
            b[c] = int(a[i]-48);
            c++;
        }
    }

    for (int i = 0; i < 9; i++) {
        s += b[i] * (i+1);
    }
    yu = s % 11;
    if(yu==10&&a[12]=='X') {
        cout << "Right";
        return 0;
    }

    else if (yu == a[12]) {
        cout << "Right";
        return 0;
    }
    else {
        for (int i = 0; i < 12; i++)
            cout << a[i];
    }
    if (s % 11 == 10)
        cout << "X";
    else
        cout << s % 11;

    return 0;
}

by zpn001 @ 2023-01-08 20:46:18

已解决


|