beizhu
#include<stdio.h>
#include<ctype.h>
#include<stdbool.h>
int quan[] = { 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 };
char m[] = { '1','0','x','8','7','6','5','4','3','2','1' };
//Z:0 1 2 3 4 5 6 7 8 9 10
//M:1 0 X 9 8 7 6 5 4 3 2
int main()
{
int x = 0, i = 0, j = 0, sum = 0, zhi, pass = 0, problem = 0;
int digit = 0;
scanf("%d", &x);
//读取并舍弃scanf后的换行符
getchar();
char idcard[19] = {[18]='\0'};
for (i = 1; i <= x; i++)
{
//sum值要刷新
sum = 0;
for (j = 0; j < 17; j++)
{
//要读取并舍弃上次printf使用后遗留下来的换行符
idcard[j] = getchar();
}
for (j = 0; j < 17; j++)
{
if (false == isdigit(idcard[j]) && j < 17)
{
printf("%s\n", idcard);//输出字符串数组要注意有没有、0
getchar();
problem = true;//要读取并舍弃上次printf使用后遗留下来的换行符,照应前文
break;
}
sum += (idcard[j] - '0') * quan[j];
}
if (problem == true)
continue;
zhi = sum % 11;
if (m[zhi] == idcard[17])
{
pass++;
}
//sum = 0;因为前面有个continue所以这句要放在for的具体循环语句的最前面
}
if (pass == x)
{
printf("All passed");
}
return 0;
}