成熟丰满熟妇高潮XXXXX,人妻无码AV中文系列久久兔费 ,国产精品一国产精品,国精品午夜福利视频不卡麻豆

您好,歡迎來到九壹網(wǎng)。
搜索
您的當前位置:首頁病人就醫(yī)管理代碼

病人就醫(yī)管理代碼

來源:九壹網(wǎng)
?

2.病人就醫(yī)管理

1.目標與要求

編寫一個程序,反應病人到醫(yī)院看病,排隊看醫(yī)生的情況。在病人排隊的過程中,主要發(fā)生兩件事。

(1) 病人到達診室,將病歷本交給護士,拍到等待隊列中候診。

(2) 護士從等待隊列中取出以為病人的病歷,該病人進入診室就診。

要求程序采用菜單方式,其選項及功能說明如下。

(1) 排隊—輸入病人的病歷號,加入到病人排隊隊列中。

(2) 就診—病人排列隊列中最前面的病人就診,并將其從隊列中刪除。

(3) 查看排隊—從隊首到隊尾列出所有的排隊病人的病歷號。

(4) 下班—退出運行。

2.工具、準備工作

在實驗開始前,應回顧或復習相關(guān)內(nèi)容。

需要一臺計算機,其中安裝有Visual C++ 6.0、Visual c++ 2005、Visual C++ 2005

Express Dev-c++或MinGW Developer Studio等集成開發(fā)環(huán)境軟件

3.實驗分析

4.代碼如下:

//頭文件:hospitalize.h

#ifndef __HOSPITALIZE_H__

#define __HOSPITALIZE_H__

#include \"lk_queue.h\" // 鏈隊列// 行醫(yī)類

class Hospitalize

{

private:

// 行醫(yī)類的數(shù)據(jù)成員:

LinkQueue queue; // 病人隊列

// 輔助函數(shù)

void StandInALine(); // 排隊

void Cure(); // 就診

void Display(); // 查看排隊

public:

// 方法聲明及重載編譯系統(tǒng)默認方法聲明:

Hospitalize(){}; // 無參數(shù)的構(gòu)造函數(shù)

~Hospitalize(){}; // 析構(gòu)函數(shù)

void Work(); // 醫(yī)生工作

};

// 行醫(yī)類的實現(xiàn)部分

void Hospitalize::StandInALine()

// 操作結(jié)果: 輸入排隊病人的病歷號,加入到病人排隊隊列中

{

unsigned int num; // 病歷號

cout << \"請輸入病歷號:\";

cin >> num; // 輸入排隊病人

queue.InQueue(num); // 將病歷號加入到病人排隊隊列中

}

void Hospitalize::Cure()

// 操作結(jié)果: 病人排隊隊列中最前面的病人就診,并將其從隊列中刪除

{

if (queue.Empty())

{ // 無病人

cout << \"現(xiàn)已沒有病人在排隊了!\" << endl;

}

else

{

unsigned int num; // 病歷號

queue.OutQueue(num); 并將其從隊列中刪除

// 病人排隊隊列中最前面的病人就診,

cout << num << \"號病人現(xiàn)在就醫(yī).\" << endl;

}

}

void Hospitalize::Display()

// 操作結(jié)果: 從隊首到隊尾列出所有的排隊病人的病歷號

{

queue.Traverse(Write); 人的病歷號

// 從隊首到隊尾列出所有的排隊病

cout << endl;

}

void Hospitalize::Work()

// 操作結(jié)果: 醫(yī)生工作

{

int select = 0;

while (select != 4)

{

cout << \"1. 排隊--輸入病人的病歷號,加入到病人隊列中\(zhòng)" << endl;

cout << \"2. 就診--病人排隊隊列中最前面的病人就診,并將其從隊列中刪除\" endl;

cout << \"3. 查看排隊--從隊首到隊尾列出所有的排隊病人的病歷號\" << endl;

cout << \"4. 下班--退出運行\(zhòng)" << endl;

cout << \"請選擇:\";

cin >> select; // 選擇功能

<< switch(select)

{

case 1:

StandInALine(); break;

case 2:

Cure(); 除

break;

case 3:

Display(); break;

}

}

// 排隊--輸入病人的病歷號,加入到病人隊列中

// 就診--病人排隊隊列中最前面的病人就診,并將其從隊列中刪

// 查看排隊--從隊首到隊尾列出所有的排隊病人的病歷號

}

#endif

//頭文件:lk_queue.h

#ifndef __LK_QUEUE_H__

#define __LK_QUEUE_H__

#include \"utility.h\" // 實用程序軟件包

#include \"node.h\" // 結(jié)點類模板

// 鏈隊列類模板

template

class LinkQueue

{

protected:

// 鏈隊列實現(xiàn)的數(shù)據(jù)成員:

Node *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 ©); // 復制構(gòu)造函數(shù)模板

LinkQueue &operator =(const LinkQueue ©);// 重載賦值運算符

};

// 鏈隊列類模板的實現(xiàn)部分

template

void LinkQueue::Init()

// 操作結(jié)果:初始化隊列

{

rear = front = new Node; // 生成頭結(jié)點

}

template

LinkQueue::LinkQueue()

// 操作結(jié)果:構(gòu)造一個空隊列

{

Init();

}

template

LinkQueue::~LinkQueue()

// 操作結(jié)果:銷毀隊列

{

Clear();

}

template

int LinkQueue::Length() const

// 操作結(jié)果:返回隊列長度

{

int count = 0; // 計數(shù)器

for (Node *tmpPtr = front->next; tmpPtr != NULL; tmpPtr = tmpPtr->next)

{ // 用tmpPtr依次指向每個元素

count++; // 對棧每個元素進行計數(shù)

}

return count;

}

template

bool LinkQueue::Empty() const

// 操作結(jié)果:如隊列為空,則返回true,否則返回false

{

return rear == front;

}

template

void LinkQueue::Clear()

// 操作結(jié)果:清空隊列

{

ElemType tmpElem; // 臨時元素值

while (Length() > 0)

{ // 隊列非空,則出列

OutQueue(tmpElem);

}

}

template

void LinkQueue::Traverse(void (*visit)(const ElemType &)) const

// 操作結(jié)果:依次對隊列的每個元素調(diào)用函數(shù)(*visit)

{

for (Node *tmpPtr = front->next; tmpPtr != NULL;

tmpPtr = tmpPtr->next)

{ // 對隊列每個元素調(diào)用函數(shù)(*visit)

(*visit)(tmpPtr->data);

}

}

template

StatusCode LinkQueue::OutQueue(ElemType &e)

// 操作結(jié)果:如果隊列非空,那么刪除隊頭元素,并用e返回其值,返回SUCCESS,

// 否則返回UNDER_FLOW,

{

if (!Empty())

{ // 隊列非空

Node *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

StatusCode LinkQueue::GetHead(ElemType &e) const

// 操作結(jié)果:如果隊列非空,那么用e返回隊頭元素,返回SUCCESS,

// 否則返回UNDER_FLOW,

{

if (!Empty())

{ // 隊列非空

Node *tmpPtr = front->next; // 指向隊列頭素

e = tmpPtr->data; // 用e返回隊頭元素

return SUCCESS;

}

else

{ // 隊列為空

return UNDER_FLOW;

}

}

template

StatusCode LinkQueue::InQueue(const ElemType &e)

// 操作結(jié)果:插入元素e為新的隊尾,返回SUCCESS

{

Node *tmpPtr = new Node(e); // 生成新結(jié)點

rear->next = tmpPtr; // 新結(jié)點追加在隊尾

rear = tmpPtr; // rear指向新隊尾

return SUCCESS;

}

template

LinkQueue::LinkQueue(const LinkQueue ©)

// 操作結(jié)果:由隊列copy構(gòu)造新隊列——復制構(gòu)造函數(shù)模板

{

Init();

for (Node *tmpPtr = copy.front->next; tmpPtr != NULL;

tmpPtr = tmpPtr->next)

{ // 對copy隊列每個元素對當前隊列作入隊列操作

InQueue(tmpPtr->data);

}

}

template

LinkQueue LinkQueue ©)

&LinkQueue::operator =(const

// 操作結(jié)果:將隊列copy賦值給當前隊列——重載賦值運算符

{

if (© != this)

{

Clear();

for (Node *tmpPtr = copy.front->next; tmpPtr != NULL;

tmpPtr = tmpPtr->next)

{ // 對copy隊列每個元素對當前隊列作入隊列操作

InQueue(tmpPtr->data);

}

}

return *this;

}

#endif

//頭文件: node.h

#ifndef __NODE_H__

#define __NODE_H__

// 結(jié)點類模板

template

struct Node

{

// 數(shù)據(jù)成員:

ElemType data; // 數(shù)據(jù)域

Node *next; // 指針域

// 構(gòu)造函數(shù)模板:

Node(); // 無參數(shù)的構(gòu)造函數(shù)模板

Node(ElemType item, Node *link = NULL); 指針建立結(jié)構(gòu)

};

// 結(jié)點類模板的實現(xiàn)部分

template

Node::Node()

// 操作結(jié)果:構(gòu)造指針域為空的結(jié)點

{

next = NULL;

}

template

// 已知數(shù)據(jù)元素值和

Node::Node(ElemType item, Node *link)

// 操作結(jié)果:構(gòu)造一個數(shù)據(jù)域為item和指針域為link的結(jié)點

{

data = item;

next = link;

}

#endif

//頭文件:utility.h

#ifndef __UTILITY_H__ #define __UTILITY_H__ // 實用程序軟件包

#ifdef _MSC_VER #if _MSC_VER == 1200 // 如果沒有定義__UTILITY_H__

// 那么定義__UTILITY_H__

// 表示是VC

// 表示VC6.0

// 標準庫頭文件

#include #include #include #include #include #include #include #include #include #include #include #include

// 標準串和操作

// 標準流操作

// 極限

// 數(shù)學函數(shù)

// 文件輸入輸出

// 字符處理

// 日期和時間函數(shù)

// 標準庫

// 標準輸入輸出

// 輸入輸出流格式設(shè)置 // 支持變長函數(shù)參數(shù)

// 支持斷言

#else // ANSI C++標準庫頭文件

#include #include #include #include #include #include #include #include #include #include #include // 其它版本的VC++

// 標準串和操作

// 標準流操作

// 極限

// 數(shù)學函數(shù)

// 文件輸入輸出

// 字符處理

// 日期和時間函數(shù)

// 標準庫

// 標準輸入輸出

// 輸入輸出流格式設(shè)置 // 支持變長函數(shù)參數(shù)

#include // 支持斷言

using namespace std; // 標準庫包含在命名空間std中

#endif // _MSC_VER == 1200

#else // ANSI C++標準庫頭文件

#include #include #include #include #include #include #include #include // 非VC

// 標準串操作

// 標準流操作

// 極限

// 數(shù)據(jù)函數(shù)

// 文件輸入輸出

// 字符處理

// 日期和時間函數(shù)

// 標準庫

#include // 標準輸入輸出

#include // 輸入輸出流格式設(shè)置

#include // 支持變長函數(shù)參數(shù)

#include // 支持斷言

using namespace std; // 標準庫包含在命名空間std中

#endif // _MSC_VER

// 自定義類型

enum StatusCode {SUCCESS, FAIL, UNDER_FLOW, OVER_FLOW,RANGE_ERROR, DUPLICATE_ERROR,

NOT_PRESENT, ENTRY_INSERTED, ENTRY_FOUND, VISITED, UNVISITED};

// 宏定義

#define DEFAULT_SIZE 1000 // 缺省元素個數(shù)

#define DEFAULT_INFINITY 1000000 // 缺省無窮大

// 實用函數(shù)(模板)聲明

static char GetChar(istream &inStream = cin); // 從輸入流inStream中跳過空格及制表符獲取一字符

static bool UserSaysYes(); 回答(no)時,返回false

// 當用戶肯定回答(yes)時, 返回true, 用戶否定

static void SetRandSeed(); // 設(shè)置當前時間為隨機數(shù)種子

static int GetRand(int n); // 生成0 ~ n-1之間的隨機數(shù)

static int GetRand(); // 生成隨機數(shù)

static int GetPoissionRand(double expectValue);// 生成期望值為expectValue泊松隨機數(shù)

template

void Swap(ElemType &e1, ElemType &e2); // 交換e1, e2之值

template

void Display(ElemType elem[], int n); // 顯示數(shù)組elem的各數(shù)據(jù)元素值

template

void Write(const ElemType &e); // 顯示數(shù)據(jù)元素

// 實用類

class Timer; // 定時器類Timer

class Error; // 通用異常類

static char GetChar(istream &inStream)

// 操作結(jié)果:從輸入流inStream中跳過空格及制表符獲取一字符

{

char ch; // 臨時變量

while ((ch = (inStream).peek()) != EOF // 文件結(jié)束符(peek()函數(shù)從輸入流中接受1

// 字符,流的當前位置不變)

&& ((ch = (inStream).get()) == ' ' // 空格(get()函數(shù)從輸入流中接受1字符,流

// 的當前位置向后移1個位置)

|| ch == '\')); // 制表符

return ch; // 返回字符

}

static bool UserSaysYes()

// 操作結(jié)果: 當用戶肯定回答(yes)時, 返回true, 用戶否定回答(no)時,返回false

{

char ch; // 用戶回答字符

bool initialResponse = true; // 初始回答

do

{ // 循環(huán)直到用戶輸入恰當?shù)幕卮馂橹?p>if (initialResponse)

{ // 初始回答

cout << \"(y, n)?\";

}

else

{ // 非初始回答

cout << \"用y或n回答:\";

}

while ((ch = GetChar()) == '\\n'); // 跳過空格,制表符及換行符獲取一字符

initialResponse = false;

} while (ch != 'y' && ch != 'Y' && ch != 'n' && ch != 'N');

while (GetChar() != '\\n'); // 跳過當前行后面的字符

if (ch == 'y' || ch == 'Y') return true;

else return false;

}

// 定時器類Timer

class Timer

{

private:

// 數(shù)據(jù)成員

clock_t startTime;

public:

// 方法聲明

Timer() { startTime = clock(); } // 構(gòu)造函數(shù)

~Timer() {}; // 析構(gòu)函數(shù)

double ElapsedTime() // 返回已過的時間

{

clock_t endTime = clock(); // 結(jié)束時間

return (double)(endTime - startTime) / (double)CLK_TCK;

// 返回從Timer對象啟動或最后一次調(diào)用reset()后所使用的CPU時間

}

void Reset() { startTime = clock(); } // 重置開始時間

};

#define MAX_ERROR_MESSAGE_LEN 100

// 通用異常類

class Error

{

private:

// 數(shù)據(jù)成員

char message[MAX_ERROR_MESSAGE_LEN];// 異常信息

public:

// 方法聲明

Error(char mes[] = \"一般性異常!\") // 構(gòu)造函數(shù)

{

strcpy(message, mes); // 復制異常信息

}

~Error(void) {}; // 析構(gòu)函數(shù)

void Show() const // 顯示異常信息

{

cout << message << endl; // 顯示異常信息

}

};

static void SetRandSeed()

// 操作結(jié)果:設(shè)置當前時間為隨機數(shù)種子

{

srand((unsigned)time(NULL));

}

static int GetRand(int n)

// 操作結(jié)果:生成0 ~ n-1之間的隨機數(shù)

{

return rand() % (n);

}

static int GetRand()

// 操作結(jié)果:生成隨機數(shù)

{

return rand();

}

static int GetPoissionRand(double expectValue)

// 操作結(jié)果:生成期望值為expectValue泊松隨機數(shù)

{

double x = rand() / (double)(RAND_MAX + 1); // x均勻分布于[0, 1)

int k = 0;

double p = exp(-expectValue); // pk為泊松分布值

double s = 0; // sk用于求和p0+p1+...+pk-1

while (s <= x)

{ // 當sk <= x時循環(huán), 循環(huán)結(jié)束后sk-1 <= x < sk

s += p; // 求和

k++;

p = p * expectValue / k; // 求下一項pk

}

return k - 1; // k-1的值服從期希值為expectValue的泊松分布

}

template

void Swap(ElemType &e1, ElemType &e2)

// 操作結(jié)果: 交換e1, e2之值

{

ElemType temp; // 臨時變量

// 循環(huán)賦值實現(xiàn)交換e1, e2

temp = e1; e1 = e2; e2 = temp;

}

template

void Display(ElemType elem[], int n)

// 操作結(jié)果: 顯示數(shù)組elem的各數(shù)據(jù)元素值

{

for (int i = 0; i < n; i++)

{ // 顯示數(shù)組elem

cout << elem[i] << \" \";

}

cout << endl;

}

template

void Write(const ElemType &e)

// 操作結(jié)果: 顯示數(shù)據(jù)元素

{

cout << e << \" \";

}

#endif

//主函數(shù)main().cpp

#include \"utility.h\" // 實用程序軟件包

#include \"hospitalize.h\" // 行醫(yī)類的頭文件

int main(void)

{

Hospitalize obj; obj.Work(); system(\"PAUSE\"); return 0; }

// 行醫(yī)類對象

// 醫(yī)生工作

// 調(diào)用庫函數(shù)system()

// 返回值0, 返回操作系統(tǒng)

因篇幅問題不能全部顯示,請點此查看更多更全內(nèi)容

Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號-2

違法及侵權(quán)請聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市萬商天勤律師事務所王興未律師提供法律服務