70分求助

P1055 [NOIP2008 普及组] ISBN 号码

weiyeen0201 @ 2024-11-10 15:43:00

#include <iostream>
#include <cstring>
using namespace std;
int main() {
    char a[14];
    cin >> a;
    int i, j = 0, sum = 0, mod;
    for (int i = 0; i <= 11; i++) {
        if (a[i] >= '0' && a[i] <= '9') {
            j++;
            sum += (a[i] - '0') * j;
        }
    }
    mod = sum % 11;
    if ((mod == a[12] - '0') || (mod == 10 && a[12] == 'X')) {
        cout << "right" << endl;
    } else {
        if (mod == 10) {
            a[12] = 'X';
            cout << a << endl;
        } else {
            a[12] = mod + '0';
            cout << a << endl;
        }
    }
    return 0;
}

by zhanghq2024 @ 2024-11-25 21:04:05

@weiyeen0201 不是哥们,“Right”R大写,看看题,求关


|