缘由https://ask.csdn.net/questions/1082358
void 验证身份证()
{//缘由https://ask.csdn.net/questions/1082358
int 权重[] = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 }, 个 = 0, j = 0, a = 0, he = 0;
char M[] = "10X98765432", 身份号[100][20]{};//19用于字符串结束20用于表示对错
cin >> 个;
while (j<个)cin >> 身份号[j++];
while (j)
if (a < 17)
if (身份号[j - 1][a] >= '0'&&身份号[j - 1][a] <= '9')
he += (身份号[j - 1][a] - '0')*权重[a], ++a;
else
身份号[j - 1][19] = '1', a = he = 0, --j;
else
if (M[(he % 11)] == 身份号[j - 1][17])
a = he = 0, --j;
else
身份号[j - 1][19] = '1', a = he = 0, --j;
cout << endl;
while (j < 个)if (身份号[j][19] == '1')cout << 身份号[j] << endl, he = ++j; else ++j;
if (he);else cout << "All passed";
}