求助

P1055 [NOIP2008 普及组] ISBN 号码

landernal @ 2022-02-01 19:12:00

#include <iostream>
using namespace std;
char s[10005];
int j, sum;
int main(){
    cin >> s;
    for(int i = 0; i <= 10; i++) {
        if(s[i] <= '9' && s[i] >= '0') {
            sum += s[i] * (j + 1);
            j++;
        }
    }
    if(s[13] == sum % 11) {
        cout << "right" << endl;
    }else{
        s[13] = sum % 11;
        cout << s << endl;
    }
    return 0;
}

by ajahjahah @ 2022-02-01 19:28:34

如果余数为10,则识别码为大写字母X

|