以下代码仅供参考
void number()
{
char buf[] = "身份证号码";
int per[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
char ver[] = "10X98765432";
int i,count;
printf("\n%d\n",strlen(buf));
for(i = 0;i < 17;i++)
count += (int)(buf[i]-'0')*per[i];
i = count % 11;
printf("i=%d\n",i);
if(ver[i] != buf[17])
{
//打印身份证号码非法
printf("error\n");
}
}