蒟蒻求助,爆零

P1055 [NOIP2008 普及组] ISBN 号码

landernal @ 2022-02-01 22:16:58

#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] - '0') * (j + 1);
            j++;
        }
    }
    if((s[13] - '0' == sum % 11 && sum % 11 < 10) || s[13] == 'X') {
        cout << "right" << endl;
    }else{
        s[13] = sum % 11 + '0';
        cout << s << endl;
    }
    return 0;
}

by landernal @ 2022-02-01 22:40:58

看下一个贴


|