50分的蒟蒻求助!!!

P1055 [NOIP2008 普及组] ISBN 号码

monalisa_K @ 2022-07-08 21:55:19

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
string str;
int t = 1, sum = 0, sbm;
int main(){
    getline(cin, str);
    for (int i = 0; i < 12; i ++){
        if (str[i] == '-')  continue;
        sum += (int(str[i]) - 48) * t;
        t ++;
    }
    sbm = sum % 11;
    if (sbm == int(str[12]) - 48)
        cout << "Right";
    else
    {
        for (int i = 0; i < 12; i ++)
            cout << str[i];
        cout << sbm;
    }
    return 0;
}

搞不懂哪里错了


by YueQian_BXFZ @ 2022-07-17 17:45:08

10(即“X”)是要特判的(我也掉坑里了……) 比如说类似6-670-82162-X


by monalisa_K @ 2022-07-19 21:13:52

@岳思恒Steven

感谢您的指教


|