国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

C++實現(xiàn)病人就醫(yī)管理系統(tǒng)

2020-01-26 13:33:07
字體:
供稿:網(wǎng)友

本文實例為大家分享了C++語言實現(xiàn)病人就醫(yī)管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

函數(shù)可實現(xiàn)反應病人到醫(yī)院看病,排隊看醫(yī)生的情況,有行醫(yī)類模板的定義及所有類函數(shù)的編寫代碼

部分代碼展示:

lk_queue.h

#ifndef __LK_QUEUE_H__#define __LK_QUEUE_H__#include "utility.h" // 實用程序軟件包#include "node.h" // 結(jié)點類模板// 鏈隊列類模板template<class ElemType>class LinkQueue {protected:// 鏈隊列實現(xiàn)的數(shù)據(jù)成員: Node<ElemType> *front, *rear; // 隊頭隊尾指指// 輔助函數(shù)模板: void Init(); // 初始化隊列public:// 抽象數(shù)據(jù)類型方法聲明及重載編譯系統(tǒng)默認方法聲明: LinkQueue(); // 無參數(shù)的構(gòu)造函數(shù)模板 virtual ~LinkQueue(); // 析構(gòu)函數(shù)模板 int Length() const; // 求隊列長度  bool Empty() const; // 判斷隊列是否為空 void Clear(); // 將隊列清空 void Traverse(void (*visit)(const ElemType &)) const ; // 遍歷隊列 StatusCode OutQueue(ElemType &e); // 出隊操作 StatusCode GetHead(ElemType &e) const; // 取隊頭操作 StatusCode InQueue(const ElemType &e); // 入隊操作 LinkQueue(const LinkQueue<ElemType> ©); // 復制構(gòu)造函數(shù)模板 LinkQueue<ElemType> &operator =(const LinkQueue<ElemType> ©);// 重載賦值運算符};// 鏈隊列類模板的實現(xiàn)部分template <class ElemType>void LinkQueue<ElemType>::Init()// 操作結(jié)果:初始化隊列{ rear = front = new Node<ElemType>; // 生成頭結(jié)點}template<class ElemType>LinkQueue<ElemType>::LinkQueue()// 操作結(jié)果:構(gòu)造一個空隊列{ Init();}template<class ElemType>LinkQueue<ElemType>::~LinkQueue()// 操作結(jié)果:銷毀隊列{ Clear(); }template<class ElemType>int LinkQueue<ElemType>::Length() const// 操作結(jié)果:返回隊列長度 { int count = 0; // 計數(shù)器  for (Node<ElemType> *tmpPtr = front->next; tmpPtr != NULL; tmpPtr = tmpPtr->next) { // 用tmpPtr依次指向每個元素 count++; // 對棧每個元素進行計數(shù) } return count;}template<class ElemType>bool LinkQueue<ElemType>::Empty() const// 操作結(jié)果:如隊列為空,則返回true,否則返回false{ return rear == front;}template<class ElemType>void LinkQueue<ElemType>::Clear() // 操作結(jié)果:清空隊列{ ElemType tmpElem; // 臨時元素值 while (Length() > 0) { // 隊列非空,則出列 OutQueue(tmpElem); }}template <class ElemType>void LinkQueue<ElemType>::Traverse(void (*visit)(const ElemType &)) const // 操作結(jié)果:依次對隊列的每個元素調(diào)用函數(shù)(*visit){ for (Node<ElemType> *tmpPtr = front->next; tmpPtr != NULL;  tmpPtr = tmpPtr->next) { // 對隊列每個元素調(diào)用函數(shù)(*visit) (*visit)(tmpPtr->data); }}template<class ElemType>StatusCode LinkQueue<ElemType>::OutQueue(ElemType &e)// 操作結(jié)果:如果隊列非空,那么刪除隊頭元素,并用e返回其值,返回SUCCESS,// 否則返回UNDER_FLOW,{ if (!Empty())  { // 隊列非空 Node<ElemType> *tmpPtr = front->next; // 指向隊列頭素 e = tmpPtr->data; // 用e返回隊頭元素 front->next = tmpPtr->next; // front指向下一元素 if (rear == tmpPtr) { // 表示出隊前隊列中只有一個元素,出隊后為空隊列 rear = front; } delete tmpPtr; // 釋放出隊的結(jié)點 return SUCCESS; } else { // 隊列為空 return UNDER_FLOW; }}template<class ElemType>StatusCode LinkQueue<ElemType>::GetHead(ElemType &e) const// 操作結(jié)果:如果隊列非空,那么用e返回隊頭元素,返回SUCCESS,// 否則返回UNDER_FLOW,{ if (!Empty())  { // 隊列非空 Node<ElemType> *tmpPtr = front->next; // 指向隊列頭素 e = tmpPtr->data; // 用e返回隊頭元素 return SUCCESS; } else { // 隊列為空 return UNDER_FLOW; }}template<class ElemType>StatusCode LinkQueue<ElemType>::InQueue(const ElemType &e)// 操作結(jié)果:插入元素e為新的隊尾,返回SUCCESS{ Node<ElemType> *tmpPtr = new Node<ElemType>(e); // 生成新結(jié)點 rear->next = tmpPtr; // 新結(jié)點追加在隊尾 rear = tmpPtr; // rear指向新隊尾 return SUCCESS;}template<class ElemType>LinkQueue<ElemType>::LinkQueue(const LinkQueue<ElemType> ©)// 操作結(jié)果:由隊列copy構(gòu)造新隊列――復制構(gòu)造函數(shù)模板{ Init(); for (Node<ElemType> *tmpPtr = copy.front->next; tmpPtr != NULL;  tmpPtr = tmpPtr->next) { // 對copy隊列每個元素對當前隊列作入隊列操作 InQueue(tmpPtr->data); }}template<class ElemType>LinkQueue<ElemType> &LinkQueue<ElemType>::operator =(const LinkQueue<ElemType> ©)// 操作結(jié)果:將隊列copy賦值給當前隊列――重載賦值運算符{ if (© != this) { Clear(); for (Node<ElemType> *tmpPtr = copy.front->next; tmpPtr != NULL;  tmpPtr = tmpPtr->next) { // 對copy隊列每個元素對當前隊列作入隊列操作 InQueue(tmpPtr->data); } } return *this;}#endif

Hospitalize.h

#ifndef __HOSPITALIZE_H__#define __HOSPITALIZE_H__#include"lk_queue.h" //鏈隊列//行醫(yī)類class HospitalListWLY{private: //行醫(yī)類數(shù)據(jù)成員 LinkQueue<unsigned int>queue; //病人隊列 //輔助函數(shù) void StandInALine(); //排隊 void Cure(); //就診 void Display(); //查看排隊public: //方法聲明及重載編譯系統(tǒng)默認方法聲明 HospitalListWLY(){}; //無參數(shù)的構(gòu)造函數(shù) ~HospitalListWLY(){}; //析構(gòu)函數(shù) void Work(); //醫(yī)生行醫(yī)工作};//行醫(yī)類的實現(xiàn)部分void HospitalListWLY::StandInALine()//操作結(jié)果:輸入病人的病歷號,加入到病人排隊隊列中{ unsigned int num; //病歷號 cout<<"請輸入病歷號:"; cin>>num; //輸入病人的病歷號 queue.InQueue(num); //將病歷號加入到病人排隊隊列中}void HospitalListWLY::Cure()//操作結(jié)果:病人排隊隊列中最前面的病人就診,將其從隊列中刪除{ if (queue.Empty()) { //無病人 cout<<"現(xiàn)已沒有病人在排隊了!"<<endl; } else { unsigned int num; //病歷號 queue.OutQueue(num); //病人排隊隊列中最前面的病人就診,并將其從隊列中刪除 cout<<num<<"號病人現(xiàn)在就醫(yī)."<<endl; }}void HospitalListWLY::Display()//操作結(jié)果:從隊首到隊尾列出所有的排隊病人的病歷號{ queue.Traverse(Write); //從隊首到隊尾列出所有的排隊病人的病歷號 cout<<endl;}void HospitalListWLY::Work()//操作結(jié)果:醫(yī)生行醫(yī)工作{ int select=0; while(select!=4) { cout<<"1。排隊―輸入排隊病人的病歷號,加入到病人隊列中."<<endl; cout<<"2.就診―病人排隊隊列中最前面的病人就診,并將其從隊列中刪除"<<endl; cout<<"3.查看排隊―從隊首到隊尾列出所有的排隊病人的病歷號"<<endl; cout<<"4.下班―退出運行"<<endl; cout<<"請選擇:"; cin>>select; //選擇功能 switch(select) { case 1: StandInALine(); //排隊――輸入病人的病歷號,加入到病人隊列中 break; case 2: Cure(); //就診――病人排隊隊列中最前面的病人就診,并將其從隊列中刪除 break; case 3: Display(); //查看隊列――從隊首到隊尾列出所有的排隊病人的病歷號 break; } }}#endif

全部代碼下載鏈接:C++語言實現(xiàn)病人就醫(yī)管理系統(tǒng)

更多學習資料請關注專題《管理系統(tǒng)開發(fā)》。

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 延长县| 温州市| 尼勒克县| 广灵县| 武冈市| 舒城县| 台江县| 大悟县| 普兰县| 农安县| 新津县| 宁德市| 同德县| 阿克| 舞阳县| 泸西县| 沿河| 通化市| 嘉黎县| 漯河市| 隆子县| 运城市| 浙江省| 灵川县| 龙陵县| 体育| 满城县| 长海县| 长宁区| 永济市| 石阡县| 咸宁市| 宣武区| 陕西省| 广东省| 木兰县| 平潭县| 尉氏县| 陆丰市| 尉氏县| 宁波市|