#include "stdafx.h"
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<string>
using namespace std;
bool check(string id)
{
const vector<int> weight = { 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 };//权值,加权平均!
const vector<char> check_code = { '1','0','X','9','8','7','6','5','4','3','2' };
int sum = 0;
for (size_t i = 0; i < 17; ++i)
{
if (!isdigit(id[i]))
return false;
string tmp(1, id[i]);
int tmp_num = stoi(tmp);
sum = sum + tmp_num*weight[i];
}
int z = sum % 11;
if (id[17] == check_code[z])
return true;
else
return false;
}
int main()
{
vector<string> input_info;
unsigned n;
cin >> n;
string tmp;
for (unsigned i = 0; i < n; ++i)
{
cin >> tmp;
if (!check(tmp))
input_info.push_back(tmp);
}
if (n == input_info.size())
cout << "All passed";
else
{
for (size_t i = 0; i < input_info.size(); ++i)
{
if (i == (input_info.size() - 1))
cout << input_info[i];
else
cout << input_info[i] << endl;
}
}
return 0;
}
网友评论