p1055 60分求助

P1055 [NOIP2008 普及组] ISBN 号码

Huchangzhi @ 2023-07-25 21:33:55

为什么是60分

#include <bits/stdc++.h>

using namespace std;

int main() {
    int shz[5][6];
    char b;
    shz[1][1] = (int) (getchar()-'1'+1);
    getchar();
    for (int i = 1; i <= 3; i++) {
        shz[2][3 + 1 - i] = (int) (getchar()-'1'+1);
    }
    getchar();
    for (int i = 1; i <= 5; i++) {
        shz[3][5 + 1 - i] = (int) (getchar()-'1'+1);
    }
    getchar();
    cin >> b;
    int c = 0;
    for (int i = 1; i <= 9; i++) {
        if (i == 1) {
            c += i * shz[1][1];
        }
        if (i >= 2 && i <= 4) {
            c += i * shz[2][i - 1];
        }
        if (i >= 5 && i <= 8) {
            c += i * shz[3][i - 4];
        }
    }
    c = c % 11;
    char d;
    if (c == 10) {
        d = 'X';
    } else {
        d = (char) (c + '1' - 1);
    }
    if (b == d) {
        printf("Right");
    } else {
        cout << shz[1][1] << "-";
        for (int i = 1; i <= 3; i++) {
            cout << shz[2][3 + 1 - i];
        }
        cout << "-";
        for (int i = 1; i <= 5; i++) {
            cout << shz[3][5 + 1 - i];
        }
        cout << "-" << d;
    }
    return 0;
}

|