这道大水题,注意X是大写
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int q[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
char m[] = {'1','0','X','9','8','7','6','5','4','3','2'};
int solve(string s)
{
long long result = 0;
for(int i = 0;i<17;i++)
{
if(!isdigit(s[i])) return -1;
result += (s[i]-'0')*q[i];
}
return result%11;
}
int main()
{
int n;
int z;
int ans = 0;
string s;
cin>>n;
for(int i = 0; i<n; i++)
{
cin>>s;
z = solve(s);
if(z<0)
{
cout<<s<<endl;
}
else
{
if(s[17] != m[z])
{
cout<<s<<endl;
}
else
{
ans++;
}
}
}
if(ans == n) cout<<"All passed"<<endl;
return 0;
}
/**
4
320124198808240056
12010X198901011234
110108196711301866
37070419881216001X
**/