/************************************************************************/
/* ID_InputInformation */
/************************************************************************/
void ID_InputInformation(IdentityInfor *head,int language)//ListCreate
{
IdentityInfor *p;
int n=1;//for count
int iCount;//counter
if(language)
printf("●How many IDs do you want to input:\n");
else
printf("●请输入你要输入的身份证个数:\n");
scanf("%d",&n);
if(n<=0)
printf("错误!请重新输入\n");
printf("●输入样例:\n");
printf("340104************ 曹俊逢男1989 11 28 安徽省合肥市西市区\n\n");
printf("NO.1:\n");
p=(IdentityInfor *)malloc(sizeof(IdentityInfor));
scanf("%s %s %s %s %s %s %s %s %s",p->IDNumber,p->name,p->sex,p->Birthday.year,p->Birthday.month,p->Birthday.day,p->Adress.pro,p->Adress.city,p->Adress.town);
for(iCount=0;iCount
{
p->next=head->next;
head->next=p;
if(iCount+1==n)break;
p=(IdentityInfor *)malloc(sizeof(IdentityInfor));
printf("NO.%d:\n",(iCount+2));
scanf("%s %s %s %s %s %s %s %s %s",p->IDNumber,p->name,p->sex,p->Birthday.year,p->Birthday.month,p->Birthday.day,p->Adress.pro,p->Adress.city,p->Adress.town);
}
system("cls");
}
/************************************************************************/
/* ID_Search */
/************************************************************************/
IdentityInfor * ID_Search(IdentityInfor *head,char ID_Number[],int language)//Search the ID
{
IdentityInfor *p;
p=head->next;
while(p!=NULL)
{
if(strcmp(p->IDNumber,ID_Number)==0)
break;
p=p->next;
}
if(p==NULL)
{ printf("●错误,没有找到该身份证信息\n");
getch();
return 0;
}
else
return p;
}
/************************************************************************/
/* ID_Display(ID) */
/************************************************************************/
void ID_Display(IdentityInfor *ID,int language)
{
system("cls");
printf("●要查寻的身份证信息为:\n");
printf("%s %s %s %s %s %s %s %s %s\n",ID->IDNumber,ID->name,ID->sex,ID->Birthday.y ear,ID->Birthday.month,ID->Birthday.day,ID->Adress.pro,ID->Adress.city,ID->Adress.town);
}
/************************************************************************/
/* ID_Pro_Number_Count */
/************************************************************************/
void ID_Pro_Number_Count(IdentityInfor *head,char Pro_Number[],int language)
{IdentityInfor *p;
int iCount=0;
p=head->next;
while(p!=NULL)
{
if(strncmp(p->IDNumber,Pro_Number,2)==0) iCount++;
p=p->next;
}
printf("●该省的人口数为:%d\n",iCount);
}
/************************************************************************/
/* ID_Area_Number_Count */
/************************************************************************/
void ID_Area_Number_Count(IdentityInfor *head,char Area_Number[],int language)
{
IdentityInfor *p;
int iCount=0;
p=head;
while(p!=NULL)
{
if(strncmp(p->IDNumber,Area_Number,6)==0) iCount++;
p=p->next;
}
printf("●该地区人口数为: %d \n",iCount);
}
/************************************************************************/
/* ID_Revise */
/************************************************************************/
void ID_Revise(IdentityInfor *ID,int language)
{
printf("●请重新输入身份证信息:\n");
scanf("%s %s %s %s %s %s %s %s %s",ID->IDNumber,ID->name,ID->sex,ID->Birthday.yea r,ID->Birthday.month,ID->Birthday.day,ID->Adress.pro,ID->Adress.city,ID->Adress.town);
}
/************************************************************************/
/* ID_Delation */
/************************************************************************/
int ID_Deletion(IdentityInfor *head,char ID_Number[])
{
IdentityInfor *p,*q;
p=head;
while(p->next!=NULL&&p->next->next!=NULL&&strcmp(p->next->IDNumber,ID_Number)!=0 )
{
p=p->next;
}
q=p->next;
p->next=p->next->next;
free(q);
return 1;
}
void ID_Judge( IdentityInfor * head,int language )
{
IdentityInfor *ID;
char Num[40],Pro[40],City[40],Town[40];
char temp[40];
int i,j,m;//for count
int n;//number of IDs
int t;
int s,w;//sum,weight
FILE *Test_Read;
printf("●请输入你要输入的身份证个数: ");
scanf("%d",&n);
for(m=1;m<=n;m++)
{
BACK:
t=1;
printf("\nNO.%d:\n",m);
while (t==1)
{
ID=( IdentityInfor * )malloc(sizeof(IdentityInfor));
s=0;
printf(" ●请输入身份证号和姓名: ");
scanf("%s%s",ID->IDNumber,ID->name);
/*====================ID calibration (身份证校验)=======================*/
/* */
/*=================================================================*/for(j=18;j>1;j--)
{
w=(int)pow(2,(j-1));
w=w%11;
s+=(ID->IDNumber[18-j]-'0')*w;
}
s=s%11;
if(s==0&&ID->IDNumber[17]=='1'||s==1&&ID->IDNumber[17]=='0'||s==2&&ID->IDNumber[17] =='x'||s==2&&ID->IDNumber[17]=='X'||s==3&&ID->IDNumber[17]=='9'||s==4&&ID->IDNumbe r[17]=='8'||s==5&&ID->IDNumber[17]=='7'||s==6&&ID->IDNumber[17]=='6'||s==7&&ID->IDNu mber[17]=='5'||s==8&&ID->IDNumber[17]=='4'||s==9&&ID->IDNumber[17]=='3'||s==10&&ID->IDNumber[17]=='2')
t=0;
else
{
printf("●输入有误,请重新输入\n");
free(ID);
t=1;
}
}
Test_Read=fopen("ID_data.txt","r");
if(Test_Read==NULL)
{
printf("Error!\n");
exit(1);
}
while(!feof(Test_Read))
{
fscanf(Test_Read,"%s%s%s%s",Num,Pro,City,Town);
if(strncmp(ID->IDNumber,Num,6)==0)
break;
}
if(strncmp(ID->IDNumber,Num,6)==0)
{
printf("\n ●你来自:%s %s %s ",Pro,City,Town);
strcpy(ID->Adress.pro,Pro);
strcpy(ID->Adress.city,City);
strcpy(ID->Adress.town,Town);
}
else
{printf(" ●没有找到!\n");
free(ID);
goto BACK;
}
/*====================Birthday_Judge=======================*/ printf("\n ●出生日期:");
for(i=6,j=0;i<10;i++,j++)
{
printf("%c",ID->IDNumber[i]);
temp[j]=ID->IDNumber[i];
}
temp[j]='\0';
strcpy(ID->Birthday.year,temp);
printf("年");
for(i=10,j=0;i<12;i++,j++)
{
printf("%c",ID->IDNumber[i]);
temp[j]=ID->IDNumber[i];
}
temp[j]='\0';
strcpy(ID->Birthday.month,temp);
printf("月");
for(i=12,j=0;i<14;i++,j++)
{
printf("%c",ID->IDNumber[i]);
temp[j]=ID->IDNumber[i];
}
temp[j]='\0';
strcpy(ID->Birthday.day,temp);
printf("日\n");
/*====================Female or Male=======================*/ if(ID->IDNumber[16]%2!=0)
{
printf(" ●性别:男\n");
strcpy(ID->sex,"男\n");
}
else
{
printf(" ●性别:女\n");
strcpy(ID->sex,"女\n");
}
fclose(Test_Read);
ID->next=head->next;
head->next=ID;
}
}
void ID_WriteToTest(IdentityInfor *head,int language)
{
IdentityInfor *p;
FILE *Test_Write;
Test_Write=fopen("ID_Write.txt","w");
if(Test_Write==NULL)
{
printf("错误!\n");
exit(1);
}
for(p=head->next;p;p=p->next)
fprintf(Test_Write,"%s %s %s %s %s %s %s %s %s\n",p->IDNumber,p->name,p->sex,p->Bir thday.year,p->Birthday.month,p->Birthday.day,p->Adress.pro,p->Adress.city,p->Adress.town);
fclose(Test_Write);
}
头文件,main()函数都没有啊,直接网上复制个函数肯定是不能运行的
请你用 “代码块” 把所有代码都传上来。