C語言版醫(yī)院管理系統(tǒng)
更新時間:2019年01月30日 15:55:51 作者:qjb742615041
這篇文章主要為大家詳細介紹了C語言版醫(yī)院管理系統(tǒng),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了C語言實現(xiàn)醫(yī)院管理系統(tǒng)的具體代碼,供大家參考,具體內容如下
#include "stdio.h" #include "string.h" #include "stdlib.h" #include "malloc.h" #define NULL 0 typedef struct { int num; char name[10]; int age; char sex; }people; //一個患者的信息 typedef struct Node { people *data; struct Node *next; }queue; // 定義隊列結構體 typedef struct { queue *front; queue *rear; }linkqueue; //定義隊列指針 int Initqueue(linkqueue *q) //初始化隊列 { q->front=(queue *)malloc(sizeof(queue)); if(q->front!=NULL) { q->rear=q->front; q->front->next=NULL; return 1; } else return 0; } int Isempty(linkqueue *Q) { if(Q->front==Q->rear) return 1; else return 0; } int Enterqueue(linkqueue *Q,people *x) { /* 將數據元素x插入到隊列Q中 */ queue *NewNode; NewNode=(queue * )malloc(sizeof(queue)); if(NewNode!=NULL) { NewNode->data=x; NewNode->next=NULL; Q->rear->next=NewNode; Q->rear=NewNode; return(1); } else return(0); /* 溢出!*/ } /*出隊操作。*/ people *Deletequeue(linkqueue *Q)/* 將隊列Q的隊頭元素出隊,并存放到x所指的存儲空間中 */ { people *x; queue *p; p=Q->front->next; Q->front->next=p->next; /* 隊頭元素p出隊 */ if(Q->rear==p) /* 如果隊中只有一個元素p,則p出隊后成為空隊 */ Q->rear=Q->front; x=p->data; free(p); /* 釋放存儲空間 */ return x; } void main() { int s,y,flag=1;//s接收病歷號,y接收年齡,flag控制循環(huán)次數。 char mz[10],d,choice;//mz[]接收姓名,d接收性別, people *x; linkqueue Q; Initqueue(&Q); printf(" *************醫(yī)院看病管理系統(tǒng)***************\n"); printf(" * *\n"); printf(" * 1 : 病人到達時請輸入 *\n"); printf(" * *\n"); printf(" * 2 : 一位患者就醫(yī)時,請輸入 *\n"); printf(" * *\n"); printf(" * 3 : 不再接收病人時,請輸入 *\n"); printf(" * *\n"); printf(" * 0 : 退出系統(tǒng),請輸入: *\n"); printf(" * *\n"); printf(" ********************************************\n"); while(flag) { printf("請輸入命令:"); flushall(); scanf("%c",&choice); switch(choice) { case'1':people r; printf("\n請輸入病歷號:"); scanf("%d",&s); r.num=s; printf("姓名:"); scanf("%s",&mz); strcpy(r.name,mz); printf("性別:"); flushall(); //程序緩沖空間函數 scanf("%c",&d); r.sex=d; printf("年齡:"); scanf("%d",&y); r.age=y; Enterqueue(&Q,&r); break; case'2':if(!Isempty(&Q)) { x=Deletequeue(&Q); printf("\n %d號病人就診!",x->num); } else printf("\n病人已全部被醫(yī)治完了!"); break; case'3':printf("\n今天停止掛號,請下列病人依次就診:"); while(!Isempty(&Q)) { x=Deletequeue(&Q); printf("%d號 ",x->num); } flag=0; break; case'0':break; default:printf("非法命令!"); } } }
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
C++/Php/Python/Shell 程序按行讀取文件或者控制臺的實現(xiàn)
下面小編就為大家?guī)硪黄狢++/Php/Python/Shell 程序按行讀取文件或者控制臺的實現(xiàn)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03