为什么全RE,求救大佬

P1055 [NOIP2008 普及组] ISBN 号码

abababwosb @ 2024-06-10 21:21:21

#include <bits/stdc++.h>
using namespace std;

int main() {
    string a, ia;
    int cnt = 0, sum = 0;
    cin >> a;

    for (int i = 0; i < a.size(); i++) {
        if (a.find('-') != -1) {
            a.erase(a.find('-'), 1);
        }
    }

    for (int i = 0; i < 9; i++) {
        sum += (int)(a[i] - '0') % 10;
        a.erase(a[i], 1);
    }

    if (sum == a[9] - '0') {
        cout << "Right";
    } else {
        cout << sum;
    }
    return 0;
}

|