西安邮电大学 C语言实习 医院管理系统 下载本文

r->next=p; r=p; } r->next=NULL; fclose(fp); printf(\文件中信息已正确读出,按任意键继续!\ getch(); return(head); }

//输出数据

void print1(struct patient *h) { struct patient *p; printf(\该医院病人数据为:\\n\ printf(\编号\\t姓名\\t性别\\t年龄\\t病况\\t电话\\t\\n\ for(p=h->next;p!=NULL;p=p->next) { printf(\,p->tele1); } printf(\按任意键返回该菜单\ getch(); Display1(); }

//查找数据 void Find1() { struct patient *p; p=read1(); find1(p); }

void find1(struct patient *p) { int id1; printf(\请输入要查找的编号:\ flushall(); scanf(\ p=p->next; while(p) { if(p->id1==id1) { {

printf(\找到了哦!\\n\ printf(\编号\\t姓名\\t性别\\t年龄\\t病况\\t电话\\n\ printf(\p->tele1); printf(\按任意键返回该菜单\ getch(); Display1(); } p=p->next; } else { printf(\很遗憾,没找到呀!\\n\ printf(\按任意键返回该菜单\ getch(); Display1(); } } }

//删除数据 void Del1() {

struct patient *p; p=read1(); if(del1(p)) { printf(\删除成功~\\n\ printf(\按任意键返回该菜单\ getch(); Display1(); } else { printf(\删除失败!\ printf(\按任意键返回该菜单\ getch(); Display1(); } }

int del1(struct patient *p0) { int id1; struct patient *p,*q; q=p0; p=p0->next; if(p==NULL) //只有头p结点为空表,不能删除返回0 return 0;

printf(\请输入要删除的编号:\ flushall(); scanf(\ while(p!=NULL) { if(p->id1=id1)//找到要删除的结点 { printf(\已删除成功~\\n\ p0->next=p->next;//后续结点链接到前驱结点之后 free(p); save1_bianji(q); return 1; } p0=p;//推移指针继续查找 p=p->next; } printf(\很遗憾没找到哦\\n\ return 0; //未找到删除的结点返回 }

//插入函数

int insert1(struct patient *p0) {

struct patient *p,*q; q=p0; p=(struct patient *)malloc(sizeof(struct patient)); printf(\编号:\ flushall(); scanf(\ printf(\姓名:\ flushall(); scanf(\ printf(\性别(请输入male(男)female(女)\ flushall(); scanf(\ printf(\年龄:\ flushall(); scanf(\ printf(\病况:\ flushall(); scanf(\ printf(\电话:\ flushall(); scanf(\ while(p0->next!=NULL&&p0->next->id1id1) p0=p0->next;

if(p0->next!=NULL && p0->next->id1==p->id1) { free(p); return 0; printf(\按任意键返回该菜单\ getch(); Display1(); } p->next=p0->next; p0->next=p; save1_bianji(q); return 1; printf(\按任意键返回该菜单\ getch(); Display1(); }

//修改病人信息 void Alter1() { struct patient *p; p=read1(); if(alter1(p)) { printf(\修改成功!\ printf(\按任意键返回该菜单\ getch(); Display1(); } else { printf(\修改失败!\ printf(\按任意键返回该菜单\ getch(); Display1(); } }

int alter1() {

struct patient *p,*h; int id1;

char choice; h=read1(); p=h->next;

printf(\请输入要修改的编号\ scanf(\ while(p!=NULL) {