溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

C語言如何實現醫院管理系統

發布時間:2021-06-12 19:04:33 來源:億速云 閱讀:449 作者:小新 欄目:編程語言

這篇文章主要介紹了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語言如何實現醫院管理系統”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女