⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hospital sys01.cpp

📁 C++语言写的basic医院系统
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        	puts(disease);
        	cout<<"\t\t\tStatus: ";
        	puts(cond);
        	cout<<"\t\t\tDays admitted :"<<adays<<endl;
        	cout<<"\t\t\tAttending doctor: ";
        	puts(doctor);
        	cout<<"\t\t\tPresently Lying in ward "<<ward<<" bed "<<bed<<endl;
        	cout<<"\t\t\tBill to be paid: "<<bill<<endl;
        	box();
        	gotoxy(0,16);
        	cout<<"\n\t\tDo you want to see address of patient(y/n): ";
        	cin>>a;
        	if(a=='y')


            	{
            		o.open("addr.txt",ios::in|ios::out|ios::app|ios::binary);
            		do


                		{
                			o.read((char*)&ad,sizeof(addr));
                			if(n==ad.n)
                			ad.view();
                		}while(o);
                		o.close();
                	}
            };
            /////////////searches the given string against its field and returns search result////////
            int patient::search(char str[20],int c)


                {
                	if(c==2)


                    	{
                    		if(strcmp(name,str)==0)
                    		return(1);
                    	}
                    	if(c==3)


                        	{
                        		if(strcmp(disease,str)==0)
                        		return(1);
                        	}
                        	if(c==4)


                            	{
                            		if(strcmp(doctor,str)==0)
                            		return(1);
                            	}
                            	if(c==5)


                                	{
                                		if(strcmp(ward,str)==0)
                                		return(1);
                                	}
                                	else
                                	return(0);
                            };
                            //////////sets doctor to a disease//////////
                            char* dis(char *d)


                                {
                                	int w;
                                	w=strcmp(d,"cancer");
                                	if(w==0)
                                	return("Dr. Tommy");
                                	w=strcmp(d,"radioactive exposure");
                                	if(w==0)
                                	return("Dr. Freeman");
                                	w=strcmp(d,"split personality");
                                	if(w==0)
                                	return("Dr. Rieper");
                                	w=strcmp(d,"bullet wound");
                                	if(w==0)
                                	return("Dr. Payne");
                                	w=strcmp(d,"ocd");
                                	if(w==0)
                                	return("Dr. Gognitti");
                                	w=strcmp(d,"pregnancy");
                                	if(w==0)
                                	return("Dr. Mathers");
                            };
                            /////////////counts no. of records//////////////
                            int count()


                                {
                                		patient p[20];
                                		fstream o;
                                		int i;
                                		o.open("hospital.txt",ios::in|ios::out|ios::binary);
                                		for(i=1;;i++)


                                    		{
                                    			o.read((char*)&p,sizeof(patient));
                                    			if(!o)
                                    			break;
                                    		}
                                    		--i;
                                    		o.close();
                                    		return(i);
                                };
                                /////////////modifys values in class 'patient'////////////
                                void modify(int rec)


                                    {
                                    			fstream o;
                                    			patient p;
                                    			o.open("hospital.txt",ios::in|ios::out|ios::binary);
                                    			o.seekg(((rec-1)*sizeof(patient)),ios::beg);
                                    			o.read((char*)&p,sizeof(patient));
                                    			if(rec==p.n)


                                        			{
                                        				clrscr();
                                        				cout<<"\t\t\tOld Values are: ";
                                        				p.out1();
                                        				clrscr();
                                        				cout<<"\t\t\tEnter New Values:(press any key) "<<endl;
                                        				getch();
                                        				clrscr();
                                        				o.seekp(((rec-1)*sizeof(patient)),ios::beg);
                                        				clrscr();
                                        				p.inp1();
                                        				o.write((char*)&p,sizeof(patient));
                                        				o.seekg(0);
                                        			}
                                        			o.close();
                                    };
                                    /////////////deletes values in class 'patient'////////////
                                    void del(int rec)


                                        {
                                        			patient p;
                                        			fstream o,d;
                                        			int flag;
                                        			o.open("hospital.txt",ios::in|ios::out|ios::binary);
                                        			d.open("temp1.txt",ios::in|ios::out|ios::binary);
                                        			clrscr();
                                        			do


                                            			{
                                            				o.read((char*)&p,sizeof(patient));
                                            				if(!o)
                                            				break;
                                            				else if(rec!=p.n)
                                            				d.write((char*)&p,sizeof(patient));
                                            				else if(rec==p.n)
                                            				flag=1;
                                            			}while(o);
                                            			addrd(rec);
                                            			cout<<"\n\n\n\t\t\tRecord No. "<<rec<<" DELETED";
                                            			box();
                                            			getch();
                                            			d.seekg(0);
                                            			d.close();
                                            			o.close();
                                            			remove("hospital.txt");
                                            			rename("temp1.txt","hospital.txt");
                                            			if(flag!=1)


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -