身份证号查询真假

...
#include
#include
using namespace std;
#define N 100
int main()
{
int n = 0;
int i,j ,k = 0;
char a[18];
char b[N][18];
int c[17] = { 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 };
int sum = 0;
int f = 0;
int x = 0;
char M[11] = { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };
int l = 0;
cin>>n;
for (i = 0; i < n; i++)
{
sum = 0;
cin>>a;
for (j = 0; j < 17; j++)
{
if (a[j] >= '0' && a[j] <= '9')
{
x = a[j] - '0';
sum += x * c[j];
}
else
{
f = 1;
}
}
sum = sum % 11;

    if ( !(M[sum] == a[j]) )
    {
        f = 1;
    }
    if (f == 0)
    {
        l++;
    }
    else
    {
        strcpy(b[k],a); 
        k++; 
    }
}
if (n == l)
{
cout<<"All passed\n";
}
else
{
    for(i = 0;i < k;i++)
    {
        for(j = 0;j < 18;j++)
        {
            cout<

...

你可能感兴趣的:(身份证号查询真假)