#include <iostream>
#include <string>
using namespace std;

int main() {
    int N;
    cin >> N;
    string id[N];
    for (int i = 0; i < N; i++) {
        cin >> id[i];
    }
    
    string M = "10X98765432";
    bool allPassed = true;
    for (int i = 0; i < N; i++) {
        string s = id[i];
        int sum = 0;
        for (int j = 0; j < 17; j++) {
            if (s[j] >= '0' && s[j] <= '9') {
                sum += (s[j] - '0') * (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2)[j];
            } else {
                allPassed = false;
                cout << s << endl;
                break;
            }
        }
        if (allPassed) {
            int Z = sum % 11;
            if (s[17] != M[Z]) {
                allPassed = false;
                cout << s << endl;
            }
        }
    }
    
    if (allPassed) {
        cout << "All passed" << endl;
    }
    
    return 0;
}
``

原文地址: https://www.cveoy.top/t/topic/hQsj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录