#include 医院挂号信息系统实验代码如下:// 医院挂号系统.#include "stdafx.h"#include<iostream>#include<iomanip>#include<fstream>#include<string>using namespace std;//******************** 医院挂号系统主菜单。 *****************//void Caidan1(){cout<<endl<<endl;cout<<"------------------ 欢迎使用医院挂号系统-----------------"<<endl;cout<<"** **"<<endl; cout<<"** 1:挂号**"<<endl; cout<<"** 2:查询挂号信息**"<<endl; cout<<"** 3:修改挂号信息**"<<endl; cout<<"** 4:查询总收入**"<<endl; cout<<"** 5:清除当天所有挂号记录**"<<endl; cout<<"** 6:退出系统..... **"<<endl; cout<<"---------------------------------------------------------"<<endl<<endl;cout<<"请选择功能项: ";}//******************** 科室菜单。 *****************//void Caidan2(){cout<<endl;cout<<"***********************************"<<endl;cout<<"** 科室菜单**"<<endl;cout<<"**-------------------------------**"<<endl;cout<<"** 0 内科**"<<endl;cout<<"** 1 外科**"<<endl;cout<<"** 2 骨科**"<<endl;cout<<"** 3 五官科**"<<endl;cout<<"***********************************"<<endl<<endl;cout<<"请选择功能项: ";}//******************** 门诊类型菜单。 *****************//void Caidan3(){cout<<endl;cout<<"***********************************"<<endl;cout<<"** 门诊类型菜单**"<<endl;cout<<"**-------------------------------**"<<endl;cout<<"** 0 普通门诊**"<<endl;cout<<"** 1 专家门诊**"<<endl;cout<<"***********************************"<<endl<<endl;cout<<"请选择功能项: ";}//******************** 结构体Guangli,用于暂时存储数据。 *****************//structGuanli{string name;string sex;intyibao_no, Birth_date;string phone_no,Keshi,Outpatient_service_type;};//******************** 病人类。 *****************//classBingren {public:Bingren();voidit_record();voidread_in();voidguahao();voidXinBinRen();void Xuanzhe(int w);void query();void alter();voidcount_money();void clear();private:Guanligl[100];intgl_len;};//******************** 用for循环对全部数组中的数据初始化。 *****************//Bingren::Bingren(){for(int i=0;i<100;i++){gl[i].phone_no=gl[i].Keshi=gl[i].Outpatient_service_type=" ## ";gl[i].yibao_no=gl[i].Birth_date =0;gl[i].sex ="##";gl[i].name ="##";}this->gl_len =0;}//******************** 初始化已有的病人纪录。 *****************//voidBingren:: it_record(){ifstreaminfile("list.txt");if (!infile){cout<<"Cannot open file.\n"<<endl;exit(0);}int yibao_no1,Birth_date1;string name1, sex1, phone_no1,Keshi1,Outpatient_service_type1;intrecord_size=0;while (!infile.eof()){infile>>yibao_no1>>name1>>sex1>>Birth_date1>>phone_no1>>Keshi1>>Outpatient_service_t ype1;if(infile.eof())break;if(yibao_no1!=0||name1==""){gl[record_size].yibao_no=yibao_no1;gl[record_size].name=name1;gl[record_size].sex=sex1;gl[record_size].Birth_date=Birth_date1;gl[record_size].phone_no=phone_no1;gl[record_size].Keshi=Keshi1;gl[record_size].Outpatient_service_type=Outpatient_service_type1;record_size++;}}record_size--;infile.close();}//******************** 将结构体中的数据存入txt文件中并覆盖原有信息。 *****************//voidBingren:: read_in(){ofstreamoutfile;outfile.open("list.txt");//,ios::out | ios::appif(!outfile){cout<<"Cannot open output file!n,";}{for(int k=0;k<100;k++)if(gl[k].yibao_no!=0)outfile<<gl[k].yibao_no<<" "<<gl[k].name<<" "<<gl[k].sex<<" "<<gl[k].Birth_date<<" "<<gl[k].phone_no<<" "<<gl[k].Keshi<<" "<<gl[k].Outpatient_service_type<<endl;}outfile.close();}//******************** 实现挂号功能。 *****************//voidBingren:: guahao(){//string keshi1="内科",keshi2="外科",keshi3="骨科",keshi4="五官科";// string Outpatient_service_type11="普通门诊",Outpatient_service_type22="专家门诊"; it_record();intcount_b=0,count_b1=0, yibao_no;cout<<"请输入医保编号:" ;cin>>yibao_no;for(int i=0;i<100;i++){if(yibao_no==gl[i].yibao_no){ count_b=i;count_b1=1;break;}}if(count_b1==1){int count1=0;for(int i=0;i<100;i++){if(gl[i].yibao_no==0){count1=i;break;}}string Keshi1,Outpatient_service_type1;cout<<"***********************************"<<endl;cout<<" 患者基本信息:医保编号、姓名、性别、出生年月、联系电话"<<endl;cout<<"医保编号:"<<gl[count_b].yibao_no<<endl;cout<<"姓名:"<<gl[count_b].name<<endl;cout<<"性别:"<<gl[count_b].sex<<endl;cout<<"出生年月:"<<gl[count_b].Birth_date<<endl;cout<<"联系电话:"<<gl[count_b].phone_no<<endl;if(gl[count_b].Keshi=="##"&&gl[count_b].Outpatient_service_type=="##"){cout<<"科室:"<<gl[count_b].Keshi<<endl;cout<<"门诊类型:"<<gl[count_b].Outpatient_service_type<<endl<<endl;cout<<"该患者今天还未挂过号!"<<endl<<endl;}if(gl[count_b].Keshi!="##"||gl[count_b].Outpatient_service_type!="##"){cout<<"科室:"<<gl[count_b].Keshi<<endl;cout<<"门诊类型:"<<gl[count_b].Outpatient_service_type<<endl<<endl;cout<<"该患者今天已挂过号!"<<endl<<endl;}cout<<"是否要挂号:1 挂号0 不挂号"<<endl;cout<<"请选择功能项: ";int m;cin>>m;while(m<0||m>1){cout<<"输入错误:请重新输入0-1的数字: ";int n;cin>>n;m=n;}if(m==1){if(gl[count_b].Keshi!="##"||gl[count_b].Outpatient_service_type!="##"){Xuanzhe( count1);gl[count1].yibao_no=gl[count_b].yibao_no;gl[count1].name=gl[count_b].name;gl[count1].sex=gl[count_b].sex;gl[count1].Birth_date=gl[count_b].Birth_date;gl[count1].phone_no=gl[count_b].phone_no;ofstreamoutfile;outfile.open("list.txt",ios::out | ios::app);//,ios::out | ios::appif(!outfile){cout<<"Cannot open output file!n,";}outfile<<gl[count1].yibao_no<<" "<<gl[count1].name<<" "<<gl[count1].sex<<" "<<gl[count1].Birth_date<<" "<<gl[count1].phone_no<<" "<<gl[count1].Keshi<<" "<<gl[count1].Outpatient_service_type<<endl;outfile.close();}if(gl[count_b].Keshi=="##"&&gl[count_b].Outpatient_service_type=="##"){Caidan3();gl[count1].yibao_no=gl[count_b].yibao_no;gl[count1].name=gl[count_b].name;gl[count1].sex=gl[count_b].sex;gl[count1].Birth_date=gl[count_b].Birth_date;gl[count1].phone_no=gl[count_b].phone_no;void read_in();}}}if(count_b1==0){ cout<<"该医保编号不存在,请重新登记:"<<endl;XinBinRen();}}//******************** //实现部分挂号功能,即实现guahao()函数中的部分功能。医院挂号信息系统