string name; string tel;
string addr; personinfo *link;
};
class UserList {
public: UserList()
{
first=new personinfo;
first->link=NULL; }
personinfo * Searchperson(string name1) {
personinfo *current=first->link ; while(current!=NULL)
if(current->name==name1) break; else current=current->link; return current;
}
bool UpdatepersonInfo(string name)
{ personinfo *current= Searchperson(name);
if(current!=NULL) { cout<<\"请输入你要更新个人信息:\"< cout<<\"电话号码: \"< cout<<\"家庭住址: \"< } else return false; } bool Deleteperson(string name) { personinfo * current,*pre; pre=first; current=first->link; while(current!=NULL) { } if(current->name==name) { pre->link=current->link; delete current; return true; break; } else { pre=current; current=current->link;} if(current==NULL) return false; } bool Add() { personinfo *current=first; while(current->link!=NULL) current=current->link; personinfo *x=new personinfo; cout<<\"请输入你要录入学生信息:\"< cout<<\"电话号码: \"< cout<<\"家庭住址: \"< x->link=NULL; return true; } void display(personinfo *x) { cout<<\"__________________________________________\"< void baocun() { } void init() { ifstream fin(\"123.txt\"); if(!fin.eof()) { string s; personinfo *current=first; while(!fin.eof()) { } current->link=NULL; fin.clear(); fin.close(); personinfo *x=new personinfo; fin>>s; x->name=s; fin>>s; if(s==\"\")break; x->tel=s; fin>>s; x->addr=s; current->link=x; current=x; ofstream myfile(\"123.txt\"); personinfo *current=first->link; while(current!=NULL) { myfile< myfile.close(); } } void AllDisp() { } personinfo *current=first->link; while(current!=NULL) { display(current); current=current->link; } private: personinfo *first; }; void main( ) { int m; bool b; string name; UserList user_list; user_list.init(); personinfo* a; while(1) { m=0; system(\"cls\");//清屏 printf(\"\\n**********通讯簿管理系统**********\\n\"); printf(\"* 1 输出 *\\n\"); printf(\"* 2 录入 *\\n\"); printf(\"* 3 查询 *\\n\"); printf(\"* 4 修改 *\\n\"); printf(\"* 5 删除 *\\n\"); printf(\"* 6 退出 *\\n\"); printf(\"************************************\\n\"); printf(\"\\n请选择(1~6):\"); scanf(\"%d\getchar(); if(m==6) break; switch(m) { case 1:user_list.AllDisp();break; case 2: } } user_list.Add(); cout<<\"增加同学成功!\\n\"; break; break; case 3: cout<<\"请输入您需查询的同学名称:\"; cin>>name; if(a=user_list.Searchperson(name)) user_list.display(a); else cout<<\"不存在该同学!\\n\"; break; case 4: cout<<\"请输入您需更新同学姓名:\"; cin>>name; b=user_list.UpdatepersonInfo(name); if(b==true) cout<<\"信息更新成功!\"< cin>>name; if(user_list.Deleteperson(name)) cout<<\"删除成功!\\n\"; else cout<<\"删除失败!\\n\"; default:printf(\"\\n选择错误!\");break; } user_list.baocun(); char ch; if(m>=1&&m<=5) { } do{ printf(\"是否继续操作,是-y/否-n \\n\"); scanf(\"%s\getchar(); }while(ch!='n'&&ch!='y'); if(ch=='n'||ch=='N') break; 因篇幅问题不能全部显示,请点此查看更多更全内容