1、#include#include#include#include#includeusing namespace std;class livers/livers 类 private:char name20; /姓名char sex;char room_num10;char parking10;char ID_num20;char phone_num20;public:livers()livers(char n20,char s,char room10,char park10,char phone20,char ID20)strcpy(name,n);sex=s;strcpy(room_num,r
2、oom);strcpy(parking,park);strcpy(phone_num,phone);strcpy(ID_num,ID);friend void menu();/友元函数;void key()char mima20,key20;char yu_mima20=“12345“;int flag;int p;char w;ifstream in;ofstream out;fstream f; /输入输出对象coutmima;coutkey;cinmima;if(strcmp(key,mima)=0)flag=1;coutp;switch(p)case 0: /修改密码coutkey;o
3、ut.open(“E:c.dat“,ios:out);out.clear();out2);coutw;coutp;if(p=1coutsex;coutroom_num;coutparking;coutphone_num;coutID_num;coutc;coutc;else flag=1;while(flag=0);while(c=y);out.close();break;case 2: /增加数据char name20,sex,room_num10,parking10,phone_num20,ID_num20,c;out.open(“E:a.dat“,ios:app);docoutname;
4、coutsex;coutroom_num;coutparking;coutphone_num;coutID_num;coutc;coutc;while(c=y);out.close();break;case 3: /修改数据char name20,sex,room_num10,parking10,phone_num20,ID_num20,c;char na20,s,room10,park10,phone20,ID20;doint flag=0;coutna;coutname;if(strcmp(name,na)=0)flag=1;coutna;coutroom;couts;coutroom;c
5、outpark;coutphone;coutID;coutc;coutc;while(c=y);break;case 4: /信息查询char name20,sex,room_num10,room10,parking10,phone_num20,ID_num20;coutk;switch(k)case 1: /按住户名查询char na20;char c;doin.open(“E:a.dat“,ios:in);in.seekg(0,ios:beg);in.clear();int flag=0;coutna;coutnamesexroom_numparkingphone_numID_num;if
6、(strcmp(name,na)=0)flag=1;coutc;coutc;while(c=y);break;case 2 : /按房间号查询doint flag=0;coutroom;coutnamesexroom_numparkingphone_numID_num;if(strcmp(room_num,room)=0)flag=1;coutc;coutc;while(c=y);break;default:coutnamesexroom_numparkingphone_numID_num;coutna;coutnamesexroom_numparkingphone_numID_num;sn=new livers(name,sex,room_num,parking,phone_num,ID_num);livn=*sn;delete sn;n+;in.close();for(i=0;i1)for(i=0;ic;coutc;while(c=y);break;case7: /退出coutw;coutp;while(w=y);/最外层的 do-while 循环/menu 函数结束int main()key();return 0;