本文实例为大家分享了C语言实现病例管理系统的具体代码,供大家参考,具体内容如下
通过十字交叉链表实现一个病例管理系统,可以查找、删除、更新信息。
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
typedef struct hospital_info{
char dise_num[10];
char ke[10];
char date[11];
char symptom[60];
char diagnosis[60];
char treatment[60];
char doctor[10];
struct hospital_info *next;
}hospitals;
typedef struct disease_info{
char dise_num[10];
char employee[10];
char sex;
char unit[30];
char date[11];
char drug_allergy[30];
char phone[12];
char addr[30];
hospitals *head_hosp;
struct disease_info *next;
}diseases;
typedef struct unit_info{
char unit_num[10];
char unit[30];
char manager[20];
char phone[12];
int total;
diseases *head_disease;
struct unit_info *next;
}units;
void create_cross_list(units**head);
void save_cross_list(units*head);
void traverse_cross_list(units*head);
void load_cross_list(units **head);
void Revise_unit(units *head);
void Revise_dise(units *head);
void Revise_hosp(units *head);
void Insert_unit(units *head);
void Insert_dise(units *head);
void Insert_hosp(units *head);
void Delete_unit(units *head);
void Delete_dise(units *head);
void Delete_hosp(units *head);
void Search_unit(units *head);
void Search_dise(units *head);
void Search_hosp(units *head);
void Display_no_hosp(units *head);
void Sortmonth(units *head);
void SortTotal(units *head);
void Sortpeople(units *head);
void main(void)
{
units *head=NULL;
short choice;
printf("-----the unit information manage system!------n");
printf("< 1----------create the cross list >n");
printf("< 2----------save the cross list >n");
printf("< 3----------traverse the cross list >n");
printf("< 4----------load the cross list >n");
printf("< 5-----------Revise information >n");
printf("< 6-----------Insert information >n");
printf("< 7-----------Delete information >n");
printf("< 8-----------Search information >n");
printf("< 9--------------- tong ji >n");
printf("< 10---------------退出 >n");
printf("--------------------------------------------->n");
f: while(1){
printf("请选择要进行的操作:(1-10)");
scanf("%hd",&choice);
getchar();
switch(choice)
{
case 1:create_cross_list(&head);
break;
case 2:save_cross_list(head);break;
case 3:traverse_cross_list(head);
break;
case 4:load_cross_list(&head);break;
case 5:
{
printf(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<unit_num);
printf("请输入单位名称:");
scanf("%s",p->unit);
printf("请输入负责人:");
scanf("%s",p->manager);
printf("请输入联系电话:");
scanf("%s",p->phone);
getchar();
p->head_disease=NULL;
p->next=hp;
hp=p;
printf("继续输入%s下单位的病例基本信息(Y/N)?n",p->unit);
scanf("%c",&ch);
getchar();
while(ch=='y'||ch=='Y')
{
pcrs=(diseases *)malloc(sizeof(diseases));
printf("请输入病例编号:");
gets(pcrs->dise_num);
printf("请输入病人姓名:");
gets(pcrs->employee);
printf("请输入性别:");
scanf("%s",&pcrs->sex);
getchar();
printf("请输入出生日期:");
gets(pcrs->date);
printf("请输入药物过敏史:");
gets(pcrs->drug_allergy);
printf("请输入联系电话:");
gets(pcrs->phone);
printf("请输入住址:");
gets(pcrs->addr);
strcpy(pcrs->unit,p->unit);
pcrs->head_hosp=NULL;
pcrs->next=p->head_disease;
p->head_disease=pcrs;
printf("继续输入%s的门诊信息(Y/N)?n",pcrs->employee);
ch=getchar();
getchar();
while(ch=='y'||ch=='Y')
{
phs=(hospitals *)malloc(sizeof(hospitals));
printf("请输入门诊科别:");
scanf("%s",phs->ke);
printf("请输入门诊时间:");
scanf("%s",phs->date);
printf("请输入症状:");
scanf("%s",phs->symptom);
printf("请输入诊断:");
scanf("%s",phs->diagnosis);
printf("请输入治疗意见:");
scanf("%s",phs->treatment);
printf("请输入医师姓名:");
scanf("%s",phs->doctor);
getchar();
strcpy(phs->dise_num,pcrs->dise_num);
phs->next=pcrs->head_hosp;
pcrs->head_hosp=phs;
printf("继续输入%s的下一条病例信息(Y/N)?n",pcrs->employee);
ch=getchar();
getchar();
}
printf("继续输入下一个病例的基本信息(Y/N)?n");
ch=getchar();
getchar();
}
printf("继续输入下一个单位的信息(Y/N)?n");
ch=getchar();
getchar();
if(ch=='y'||ch=='Y')
goto loop;
(*head)=hp;
p=(*head);
}
void save_cross_list(units *head)
{
FILE *out1,*out2,*out3;
units *p=head;
diseases *pcrs;
hospitals *phs;
if((out1=fopen("c:\unit.dat","wb+"))==NULL)
exit(-1);
if((out2=fopen("c:\disease.dat","wb+"))==NULL)
exit(-1);
if((out3=fopen("c:\hospital.dat","wb+"))==NULL)
exit(-1);
while(p!=NULL)
{
fwrite(p,sizeof(units),1,out1);
pcrs=p->head_disease;
while(pcrs!=NULL)
{
fwrite(pcrs,sizeof(diseases),1,out2);
phs=pcrs->head_hosp;
while(phs!=NULL)
{
fwrite(phs,sizeof(hospitals),1,out3);
phs=phs->next;
}
pcrs=pcrs->next;
}
p=p->next;
}
fclose(out1);
fclose(out2);
fclose(out3);
printf("记录已被保存.n");
}
void traverse_cross_list(units *head)
{
units *p=head;
diseases *pcrs;
hospitals *phs;
printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<unit_num,p->unit,p->manager,p->phone);
pcrs=p->head_disease;
while(pcrs!=NULL)
{
printf("%st%st%ct%st%st%st%st%sn",pcrs->dise_num,pcrs->employee,
pcrs->sex,pcrs->unit,pcrs->date,pcrs->drug_allergy,pcrs->phone,pcrs->addr);
phs=pcrs->head_hosp;
while(phs!=NULL)
{
printf("%st%st%st%st%st%st%sn",phs->dise_num,phs->ke,phs->date,
phs->symptom,phs->diagnosis,phs->treatment,phs->doctor);
phs=phs->next;
}
pcrs=pcrs->next;
}
p=p->next;
}
printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<head_disease=NULL;
p->next=hp;
hp=p;
}
}
(*head)=hp;
while(!feof(in2))
{
pcrs=(diseases *)malloc(sizeof(diseases));
fread(pcrs,sizeof(diseases),1,in2);
if(!feof(in2))
{
p=(*head);
pcrs->head_hosp=NULL;
while(p!=NULL)
{
if(!strcmp(p->unit,pcrs->unit))
{
pcrs->next=p->head_disease;
p->head_disease=pcrs;
break;
}
else p=p->next;
}
}
}
(*head)=hp;
while(!feof(in3))
{
phs=(hospitals *)malloc(sizeof(hospitals));
fread(phs,sizeof(hospitals),1,in3);
if(!feof(in3))
{
p=(*head);
while(p!=NULL)
{
pcrs=p->head_disease;
while(pcrs!=NULL)
{
if(!strcmp(phs->dise_num,pcrs->dise_num))
{
phs->next=pcrs->head_hosp;
pcrs->head_hosp=phs;
break;
}
else pcrs=pcrs->next;
}
p=p->next;
}
}
}
fclose(in1);
fclose(in2);
fclose(in3);
}
//修改一个单位基本信息
void Revise_unit(units *head)
{
units *p,*q;
char num[10];
char choice;
char update[30];
p=q=head;
printf("please input 要修改的单位编号:");
scanf("%s",num);
getchar();
while(strcmp(num,p->unit_num)!=0&&p->next!=0)
{
q=p;
p=p->next;
}
if(strcmp(num,p->unit_num)==0)
{
printf(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<unit_num,update,strlen(update)+1);
goto loop;
case 'b':
scanf("%s",update);
strncpy(p->unit,update,strlen(update)+1);
goto loop;
case 'c':
scanf("%s",update);
strncpy(p->manager,update,strlen(update)+1);
goto loop;
case 'd':
scanf("%s",update);
strncpy(p->phone,update,strlen(update)+1);
goto loop;
default:break;
}
printf("修改成功!n");
}
else printf("not find!n");
}
//修改一个病历基本信息
void Revise_dise(units *head)
{
units *p;
diseases *pcrs;
char num[10];
char update[30];
char choice;
p=head;
printf("please input 要修改信息的员工编号:");
scanf("%s",num);
getchar();
pcrs=p->head_disease;
while(p!=NULL)
{
while(pcrs!=NULL)
{
if(strcmp(pcrs->dise_num,num)==0)
goto loop1;
pcrs=pcrs->next;
}
p=p->next;
pcrs=p->head_disease->next;
}
if(p==NULL)
{
printf("not find the unit");
goto end;
}
loop1:
printf(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<dise_num,update,sizeof(update)+1);
goto loop2;
case 'b':
scanf("%s",update);
strncpy(pcrs->employee,update,sizeof(update)+1);
goto loop2;
case 'c':
scanf("%c",&pcrs->sex);
goto loop2;
case 'd':
scanf("%s",update);
strncpy(pcrs->unit,update,strlen(update)+1);
goto loop2;
case 'e':
scanf("%s",update);
strncpy(pcrs->date,update,strlen(update)+1);
goto loop2;
case 'f':
scanf("%s",update);
strncpy(pcrs->drug_allergy,update,strlen(update)+1);
goto loop2;
case 'g':
scanf("%s",update);
strncpy(pcrs->phone,update,strlen(update)+1);
goto loop2;
case 'h':
scanf("%s",update);
strncpy(pcrs->addr,update,strlen(update)+1);
goto loop2;
default:break;
}
printf("修改成功!n");
end: ;
}
void Revise_hosp(units *head)
{
units *p;
diseases *pcrs;
hospitals *phs;
char num[10],date[11];
char choice;
char update[30];
p=head;
printf("please input 要修改信息的病历编号:");
scanf("%s",num);
pcrs=p->head_disease;
while(p!= NULL)
{
while(pcrs!= NULL)
{
if(strcmp(pcrs->dise_num,num)==0)
goto loop1;
pcrs=pcrs->next;
}
p=p->next;
pcrs=p->head_disease->next;
}
if(p==NULL)
{
printf("not find the unit");
goto end;
}
loop1:
printf("please input 要修改信息的门诊时间:");
scanf("%s",date);
phs=pcrs->head_hosp;
while(phs!= NULL)
{
if(strcmp(phs->date,date)==0)
goto loop2;
phs=phs->next;
}
if(phs==NULL)
{
printf("not find ");
goto end;
}
loop2:
printf(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<dise_num,update,strlen(update)+1);
goto loop3;
case 'b':
strncpy(phs->ke,update,strlen(update)+1);
goto loop3;
case 'c':
strncpy(phs->date,update,strlen(update)+1);
goto loop3;
case 'd':
strncpy(phs->symptom,update,strlen(update)+1);
goto loop3;
case 'e':
strncpy(phs->diagnosis,update,strlen(update)+1);
goto loop3;
case 'f':
strncpy(phs->treatment,update,strlen(update)+1);
goto loop3;
case 'g':
strncpy(phs->doctor,update,strlen(update)+1);
goto loop3;
default:break;
}
printf("修改成功!n");
end: ;
}
//按单位编号由小到大在链表中插入一个单位新结点
void Insert_unit(units *head)
{
units *p1,*p2;
int state;
loop:
p1=head;
p2=malloc(sizeof(units));
p2->next=NULL;
p2->head_disease=malloc(sizeof(diseases));
p2->head_disease->next=NULL;
printf("请输入单位编号:");
scanf("%s",p2->unit_num);
a: while(p1->next!=NULL)
{
p1=p1->next;
if(strcmp(p1->unit_num,p2->unit_num)==0)
{
state = 1;
break;
}
else
{
state=0;
break;
}
}
switch(state)
{
case 0:if(strcmp(p1->unit_num,p2->unit_num)>0)
{
if(p1==head->next)
{
head->next=p2;
p2->next=p1;
}
else
{
p1->next=p2;
p2->next=p1->next;
}
break;
}
else
goto a;
case 1:printf("the unit num already exit,pleae input another onen");
goto loop;
}
printf("请输入单位名称:");
scanf("%s",p2->unit);
printf("请输入负责人:");
scanf("%s",p2->manager);
printf("请输入联系电话:");
scanf("%s",p2->phone);
printf("插入成功!n");
}
//按病历编号由小到大插入一个员工病历信息结点
void Insert_dise(units *head)
{
units *p;
diseases *pcrs1,*pcrs2;
int state;
char name[30];
printf("请输入单位名称:");
scanf("%s",name);
p=head;
while(p->next!= NULL)
{
p=p->next;
if (strcmp(p->unit,name)==0)
break;
}
if(p==NULL)
{
printf("not find the unit!");
goto end;
}
pcrs1=p->head_disease;
pcrs2=malloc(sizeof(diseases));
pcrs2->next = NULL;
pcrs2->head_hosp= malloc(sizeof(hospitals));
pcrs2->head_hosp->next=NULL;
strcpy(pcrs2->unit,name);
loop:
printf("请输入病例编号:");
scanf("%s",pcrs2->dise_num);
if (pcrs1==NULL)
p->head_disease->next = pcrs2;
else
{
a: while (pcrs1 ->next != NULL)
{
pcrs1= pcrs1->next;
if (strcmp(pcrs1->dise_num,pcrs2->dise_num)==0)
{
state = 1;
break;
}
else
{
state=0;
break;
}
}
switch(state)
{
case 0:if(strcmp(pcrs1->dise_num,pcrs2->dise_num)>0)
{
if(pcrs1=p->head_disease->next)
{
p->head_disease->next=pcrs2;
pcrs2->next=pcrs1;
}
else
{
pcrs1->next=pcrs2;
pcrs2->next=pcrs1->next;
}
break;
}
else
goto a;
case 1:printf("the disease number already exit,please input another onen");
goto loop;
}
}
printf("请输入姓名:");
scanf("%s",pcrs2->employee);
printf("请输入性别:");
scanf("%c",pcrs2->sex);
printf("请输入出生日期");
scanf("%s",pcrs2->date);
printf("请输入药物过敏史:");
scanf("%s",pcrs2->drug_allergy);
printf("请输入联系电话:");
scanf("%s",pcrs2->phone);
printf("请输入住址:");
scanf("%s",pcrs2->addr);
printf("插入成功!n");
end: ;
}
//按门诊时间由小到大插入一个员工门诊信息结点
void Insert_hosp(units *head)
{
units *p;
diseases *pcrs;
hospitals *phs1,*phs2;
char number[10];
printf("请输入单位编号:");
scanf("%s",number);
p=head;
while(p->next!= NULL)
{
p=p->next;
if(strcmp(p->unit_num,number)==0)
break;
}
if(p==NULL)
{
printf("not find the unitn");
goto end;
}
pcrs=p->head_disease;
printf("请输入病例编号:");
scanf("%s",number);
while(pcrs->next!=NULL)
{
pcrs=pcrs->next;
if (strcmp(pcrs->dise_num,number)==0)
break;
}
if (pcrs==NULL)
{
printf("not find the question n");
goto end;
}
phs1=pcrs->head_hosp->next;
phs2=malloc(sizeof(hospitals));
phs2->next=NULL;
if(phs1==NULL)
pcrs->head_hosp->next =phs2;
else
{
while(phs1->next!=NULL)
phs1=phs1->next;
phs1->next=phs2;
}
strncpy(phs2->dise_num,number,strlen(number)+1);
printf("请输入科别:");
scanf("%s",phs2->ke);
printf("请输入诊断时间:");
scanf("%s",phs2->date);
printf("请输入主诉:");
scanf("%s",phs2->symptom);
printf("请输入初步诊断:");
scanf("%s",phs2->diagnosis);
printf("请输入治疗意见:");
scanf("%s",phs2->treatment);
printf("请输入医师姓名:");
scanf("%s",phs2->doctor);
printf("插入成功!n");
end: ;
}
void Delete_unit(units *head)
{
units *p,*q;
char name[30];
printf("please input 要删除的单位名称:");
scanf("%s",name);getchar();
p=q=head;
while(strcmp(name,p->unit)!=0&&p->next!=0)
{
q=p;
p=p->next;
}
if(strcmp(name,p->unit)==0)
{
if(p==head) head=p->next;
else q->next=p->next;
free(p);
printf("删除成功!n");
}
else printf("%s not been found!n",name);
}
void Delete_dise(units *head)
{
units *p,*q;
diseases *pcrs,*t;
char name[10],employee[30];
printf("please input 要删除信息的单位名称:");
scanf("%s",name);
getchar();
p=q=head;
while(strcmp(name,p->unit)!=0&&p->next!=0)
{
q=p;
p=p->next;
}
if(strcmp(name,p->unit)==0)
{
printf("please input 要删除信息的员工姓名:");
scanf("%s",employee);
getchar();
pcrs=t=p->head_disease;
while(strcmp(employee,pcrs->employee)!=0&&pcrs->next!=0)
{
t=pcrs;
pcrs=pcrs->next;
}
if(strcmp(employee,pcrs->employee)==0)
{
if(pcrs==p->head_disease) p->head_disease=pcrs->next;
else t->next=pcrs->next;
free(pcrs);
printf("删除成功!n");
}
}
else printf("%s not been found!n",employee);
}
//删除一条门诊信息记录
void Delete_hosp(units *head)
{
units *p,*q;
diseases *pcrs,*t1;
hospitals *phs,*t2;
char name[30],employee[10],date[11];
printf("please input 要删除信息的单位名称:");
scanf("%s",name);
getchar();
p=q=head;
while(strcmp(name,p->unit)!=0&&p->next!=0)
{
q=p;
p=p->next;
}
if(strcmp(name,p->unit)==0)
{
printf("please input 要删除信息的员工姓名:");
scanf("%s",employee);
getchar();
pcrs=t1=p->head_disease;
while(strcmp(employee,pcrs->employee)!=0&&pcrs->next!=0)
{
t1=pcrs;
pcrs=pcrs->next;
}
if(strcmp(employee,pcrs->employee)==0)
{
printf("please input 要删除信息的病历时间:");
scanf("%s",date);
getchar();
phs=t2=pcrs->head_hosp;
while(strcmp(date,phs->date)!=0&&phs->next!=0)
{
t2=phs;
phs=phs->next;
}
if(strcmp(date,phs->date)==0)
{
if(phs==pcrs->head_hosp) pcrs->head_hosp=phs->next;
else t2->next=phs->next;
free(phs);
printf("删除成功!n");
}
}
}
else printf("%s not been found!n",date);
}
void Search_unit(units *head)
{
units *p,*q;
char num[10];
p=q=head;
printf("please input 要查询的单位编号:");
scanf("%s",num);
getchar();
while(strcmp(num,p->unit_num)!=0&&p->next!=0)
{
q=p;
p=p->next;
}
if(strcmp(num,p->unit_num)==0)
{
printf("单位编号:%sn",p->unit_num);
printf("单位名称:%sn",p->unit);
printf("负责人:%sn",p->manager);
printf("联系电话:%sn",p->phone);
}
else printf("%s not been found!n",num);
}
//查询一条病历信息链并输出信息
void Search_dise(units *head)
{
units *p,*q;
diseases *pcrs,*t;
char name[10],num[10];
p=q=head;
printf("please input 要查询的单位名称:");
scanf("%s",name);
getchar();
while(strcmp(name,p->unit)!=0&&p->next!=0)
{
q=p;
p=p->next;
}
if(strcmp(name,p->unit)==0)
{
pcrs=t=p->head_disease;
printf("please input 要查询的病历编号:");
scanf("%s",num);
getchar();
while(strcmp(num,pcrs->dise_num)!=0&&pcrs->next!=0)
{
t=pcrs;
pcrs=pcrs->next;
}
if(strcmp(num,pcrs->dise_num)==0)
{
printf("病历编号:%sn",pcrs->dise_num);
printf("姓名:%sn",pcrs->employee);
printf("性别:%cn",pcrs->sex);
printf("工作单位:%sn",pcrs->unit);
printf("出生日期:%sn",pcrs->date);
printf("药物过敏史:%sn",pcrs->drug_allergy);
printf("联系电话:%sn",pcrs->phone);
printf("住址:%sn",pcrs->addr);
}
}
else printf("not been found!n");
}
//查询一条门诊信息链并输出信息
void Search_hosp(units *head)
{
units *p,*q;
diseases *pcrs,*t1;
hospitals *phs,*t2;
char name[10],num[10],date[11];
p=q=head;
printf("please input 要查询的单位名称:");
scanf("%s",name);
getchar();
while(strcmp(name,p->unit)!=0&&p->next!=0)
{
q=p;
p=p->next;
}
if(strcmp(name,p->unit)==0)
{
pcrs=t1=p->head_disease;
printf("please input 要查询的病历编号:");
scanf("%s",num);
getchar();
while(strcmp(num,pcrs->dise_num)!=0&&pcrs->next!=0)
{
t1=pcrs;
pcrs=pcrs->next;
}
if(strcmp(num,pcrs->dise_num)==0)
{
phs=t2=pcrs->head_hosp;
printf("please input 要查询的门诊时间:");
scanf("%s",date);
getchar();
while(strcmp(date,phs->date)!=0&&phs->next!=0)
{
t2=phs;
phs=phs->next;
}
if(strcmp(date,phs->date)==0)
{
printf("病历编号:%sn",phs->dise_num);
printf("诊断科别:%sn",phs->ke);
printf("门诊时间:%sn",phs->date);
printf("主诉:%sn",phs->symptom);
printf("初步诊断:%sn",phs->diagnosis);
printf("治疗意见:%sn",phs->treatment);
printf("医师姓名:%sn",phs->doctor);
}
}
}
else printf("not been found!n");
}
void Display_no_hosp(units *head)
{
units *p=head;
diseases *pcrs;
hospitals *phs;
while(p!=NULL)
{
printf("%sn",p->unit); //输出各个单位名称
printf("员工姓名t电话t住址n");
pcrs=p->head_disease;
while(pcrs!=NULL)
{
phs=pcrs->head_hosp;
//如果phs是空链,则该员工从未门诊过
if(phs==NULL)
printf("%st%st%sn",pcrs->employee,pcrs->phone,pcrs->addr);
else ; //否则门诊过,执行空语句
pcrs=pcrs->next;
}
p=p->next;
}
}
void Sortmonth(units *head)
{
units *p=head;
diseases *pcrs;
hospitals *phs;
int s[12],i,j,t,count;
char year[10],month[10];
for(i=0;i<12;i++) s[i]=0;
printf("--请输入要统计的年份:"); //手动输入要统计的年份
scanf("%s",year);
getchar();
printf("--请输入要统计的月份:");
for(i=0;i<12;i++)
{
count=0; //统计一年中各月的门诊量
scanf("%s",month);
while(p!=NULL)
{
pcrs=p->head_disease;
while(pcrs!=NULL)
{
phs=pcrs->head_hosp;
while(phs!=NULL)
{
j=0;
while(phs->date[j]==year[j]&&(j<4))
j++;//判断是否为要统计的年份
if(j==4) //是,比较是否为在该月的门诊
if(phs->date[j+1]==month[0]&&phs->date[j+2]==month[1])
count++;
else ; //不是,执行空语句
phs=phs->next;
}
pcrs=pcrs->next;
}
p=p->next;
}
s[i]=count;
}
for(i=0;i<12;i++) //输出各月的总门诊量
printf("%dt",s[i]);
printf("n");
for(i=0;i<11;i++) //降序排序
for(j=0;j<11-i;j++)
if(s[j]total=0;
count=0;
pcrs=p->head_disease;
while(pcrs!=NULL)
{
phs=pcrs->head_hosp;
while(phs!=NULL)
{
count++;
phs=phs->next;
}
pcrs=pcrs->next;
}
p->total=count;
printf("%st",p->unit); //输出各个单位名称
p=p->next;
}
printf("n");
p=head; //遍历指针p指向头指针
while(p!=NULL)
{ //输出统计数
printf("%dt",p->total);
p=p->next;
}
printf("n");
p=head;
while(p!=NULL)
{ //计算单位信息链表长度
len++;
p=p->next;
}
for(i=0,p=head;inext) //对统计量降序排序
for(j=i+1,q=p->next;jnext)
if(p->totaltotal)
{
t=p->total;
p->total=q->total;
q->total=t;
}
p=head;
printf("请输出按降序排列后的统计量:n");
while(p!=NULL)
{ //输出排序后的统计量
printf("%dt",p->total);
p=p->next;
}
printf("n");
}
//统计各单位员工总人数并输出
void Sortpeople(units *head)
{
units *p=head;
diseases *pcrs;
int count;
while(p!=NULL)
{
p->total=0;
count=0;
pcrs=p->head_disease;
while(pcrs!=NULL)
{
count++;
pcrs=pcrs->next;
}
p->total=count;
p=p->next;
}
p=head;
while(p!=NULL)
{
printf("输出单位名称:%s",p->unit);
printf("统计单位总人数:%dn",p->total);
p=p->next;
}
}
更多学习资料请关注专题《管理系统开发》。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



