80分求助!! 4 和 7 过不了

P1055 [NOIP2008 普及组] ISBN 号码

pku_lmc @ 2024-04-28 12:38:37

#include <iostream>
#include <string>
using namespace std;
int main(){
    int num = 0, k = 0;
    string s;
    getline(cin, s);
    for(int i = 0; i < 11; ++i)
        if(s[i] >= '0'&&s[i] <= '9') {k++;num += (s[i] - '0')*k;}
    if(num%11 == s[12] - '0'||(num == 10&& s[12]=='X')) cout << "Right";
    else {
        if(num%11 == 10) s[12] = 'X';
        else s[12] = num%11 + '0';
        cout << s;
    }
}

by pku_lmc @ 2024-04-28 13:15:34

脑残了(num%11==10


by Liuboom @ 2024-04-28 13:19:25


    if(num%11 == s[12] - '0'||(num == 10&& s[12]=='X')) cout << "Right"

改成


    if(num%11 == s[12] - '0'||(num%11 == 10&& s[12]=='X')) cout << "Right"

|