#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct person
{ char num[5];
char name[20];
char card[18];
char sex;
char birthday[13];
char place[10];
int education;
char telephone[11];
int seniority;
float salary;
char address[30];
struct person *next;
};
typedef struct person file;
void findname(file *head) //按名字查找
{
char name[20] = {0};
printf("输入一个人的名字!\n");
scanf("%s",&name);
if(strlen(name) > 20) // 判断输入的名字是否符合要求
{
printf("对不起,您编号输入有问题,请输入正确的籍贯格式!\n");
return;
}
file *p = head;
while(p != NULL)
{
if(strcmp(p->name,name) == 0) //若找到此人,输入此人的信息
{
printf("姓名为 %s 的人的信息是: \n",name);
printf("编号 姓名 身份证号 性别 出生日期 籍贯 学历 薪资 电话 工龄 地址\n");
printf("%-4s %-20s %-20s %-4c",p->num,p->name,p->card,p->sex);
printf("%-12s %-10s %-2d %-10.3f ",p->birthday,p->place,p->education,p->salary);
printf("%-15s %-4d %-30s\n",p->telephone,p->seniority,p->address);
break;
}
p = p->next;
}
if(p == NULL)
printf("对不起,目前没有此人信息\n");
}
void findnum(file *head) // 按编号查找
{
char num[5] = {0};
printf("输入一个人的编号!\n");
scanf("%s",num);
if(strlen(num) > 4) // 判断输入的编号是否符合要求
{
printf("对不起,您编号输入有问题,请输入四位的编号!\n");
return;
}
file *p = head;
while(p != NULL)
{
if(strcmp(p->num,num) == 0)
{
printf("编号为%s的人的信息为:\n ",num);
printf("编号 姓名 身份证号 性别 出生日期 籍贯 学历 薪资 电话 工龄 地址\n");
printf("%-4s %-20s %-20s %-4c",p->num,p->name,p->card,p->sex);
printf("%-12s %-10s %-2d %-10.3f ",p->birthday,p->place,p->education,p->salary);
printf("%-15s %-4d %-30s\n",p->telephone,p->seniority,p->address);
break;
}
p = p->next;
}
if(p == NULL)
printf("对不起,目前没有此编号人信息\n");
}
void findpalace(file *head) //按照籍贯查找
{
char palace[10] = {0};
printf("输入一个籍贯!\n");
scanf("%s",palace);
if(strlen(palace) > 10) // 判断输入的籍贯是否符合要求
{
printf("对不起,您编号输入有问题,请输入正确的籍贯格式!\n");
return;
}
file *p = head;
while(p != NULL)
{
if(strcmp(p->place,palace) == 0)
{
printf("籍贯是%s的人的信息是