//zhuhu.txt保存了所有客户的信息 if(!infile) { }
for(i=0;i infile.read((char *)p1,sizeof(Zhuhu));//运用二进制文件操作函数,方便快cerr<<\ abort(); 捷,不用重载 if(i==0) head=p1; p2=new Zhuhu; if(i==count-1) p1->next=NULL; else {p1->next=p2; p1=p2;} ;} infile.close();//关闭文件,防止误操作 Zhuhu *jianli(Zhuhu *head);//建立数据库函数声明 void shuchu(Zhuhu *head); Zhuhu *charu(Zhuhu *head); Zhuhu *shanchu(Zhuhu *head); void zhixing(Zhuhu *head); void chaxun(Zhuhu *head);//查询功能函数 void tongji(Zhuhu *head); void paixu(Zhuhu *head); string con=\ cout<<\※※※※※※欢迎进入小区物业管理系统※※※※※※※※\cout<<\ 开发人:秦国栋\(07电子信息1班)\if(count==0) 11 {cout<<\ _____\ cout<<\警告★★您的数据库是空的,请首先建立数据库!!!!★★\cout<<\ ____\ while(con!=\while(con!=\循环命令机制,这种比较方便,简单 { cout<<\建立数据库\cout<<\输出所有信息\cout<<\添加住户\cout<<\删除住户\cout<<\收费功能\cout<<\查询功能\cout<<\统计空房\cout<<\排序功能\ cout<<\退出系统,保存数据\cout<<\我的命令是********:-->\cin>>con; &&con!=\ { } cout<<\错误命令,重新输入:\cin>>con; if(con==\ head=jianli(head); if(con==\ shuchu(head); if(con==\ 12 head=charu(head); if(con==\ head=shanchu(head); if(con==\ zhixing(head); if(con==\ chaxun(head); if(con==\ tongji(head); if(con==\ paixu(head); cout<<\提示[*操作完毕请选择退出程序(选择命令[0]),否则您的数据将 不能保存!*]\必须退出 }; //务必退出程序,否则处理结果无法保存 p1=head; ofstream countfile(\ if(!countfile) { } cerr<<\ abort(); countfile< ofstream outfile(\ if(!outfile) { } 13 cerr<<\abort(); } for(i=0;i outfile.close(); return 0; outfile.write((char *)p1,sizeof(Zhuhu)); p1=p1->next; Zhuhu *jianli(Zhuhu *head) {Zhuhu *p1,*p2; if(count>0)//此时不允许录入数据,只能使用添加功能录入 {cout<<\警告!!您的数据库已经存在,若要重新建立,请清除zhuhu文件内容并使count文件归0\ cout<<\_______\} if(count==0) { p1=p2=new Zhuhu; head=p1; int n; cout<<\请输入需要建立的住户数:\cin>>n; for(int i=0;i cout<<\第\位住户信息\p1->input_message(); p1=new Zhuhu; 14 if(i==n-1) p2->next=NULL; else p2->next=p1; p2=p1; } if(i==n) p2->next=NULL; count=n; } return head; } void shuchu(Zhuhu *head) {Zhuhu *p1; p1=head; while(p1!=NULL) { p1->show_message(); p1=p1->next; } ;} Zhuhu *charu(Zhuhu *head) { cout<<\请输入要添加住户的详细信息:\ Zhuhu *p0,*p1,*p2,*p3; p3=p1=head; p0=new Zhuhu; p0->input_message(); while(p3->next!=NULL) { if(p3->get_num()==p0->get_num()) {cout<<\您输入输入输入的房号有误或非空房,请重新输入!\ p0->input_message(); } p3=p3->next; 15