这篇文章主要介绍了C语言如何实现医院管理系统,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
本文实例为大家分享了C语言实现医院管理系统的具体代码,供大家参考,具体内容如下
#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控制循环次数。
char mz[10],d,choice;//mz[]接收姓名,d接收性别,
people *x;
linkqueue Q;
Initqueue(&Q);
printf(" *************医院看病管理系统***************\n");
printf(" * *\n");
printf(" * 1 : 病人到达时请输入 *\n");
printf(" * *\n");
printf(" * 2 : 一位患者就医时,请输入 *\n");
printf(" * *\n");
printf(" * 3 : 不再接收病人时,请输入 *\n");
printf(" * *\n");
printf(" * 0 : 退出系统,请输入: *\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病人已全部被医治完了!");
break;
case'3':printf("\n今天停止挂号,请下列病人依次就诊:");
while(!Isempty(&Q))
{
x=Deletequeue(&Q);
printf("%d号 ",x->num);
}
flag=0;
break;
case'0':break;
default:printf("非法命令!");
}
}
}
感谢你能够认真阅读完这篇文章,希望小编分享的“C语言如何实现医院管理系统”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。