简单个人电话号码查询系统
的有关信息介绍如下:
#include #include #include using namespace std; int x=0; char a; int j=1; struct TeleNumber //数据类{char name[10]; //姓名int phoneNumber; //固定电话号码int mobileNumber; //移动电滑辩扮话号码char email[10]; //电子邮箱int s; TeleNumber * Next; void ReadFile(istream & in); void input(); void display(); } ; void TeleNumber::ReadFile(istream & in) //从文件把数据读入到程序{in>>name>>phoneNumber>>mobileNumber>>email; } void TeleNumber::input() //信息输入{cout<<"请输入姓名"<>name; cout<<"请输入固定电话号码"<>phoneNumber; cout<<"请输入移动电话号码"<>mobileNumber; cout<信灶<"请输入电子邮箱"<>email; s=j++; } void TeleNumber::display() //信息输出{cout<<"姓名:"<Next=new TeleNumber; End=Head->Next; in.open("TeleNumber.text"); //打开外存文件,看是否有数据存在if(!in) cout<<"灶虚电话系统中没有任何号码,请输入号码"<ReadFile(in); if(End->name[0]=='\0')break; End->Next=new TeleNumber; End=End->Next; } in.close(); cout<<"读取电话号码系统成功!"<>a; } TeleMessage::~TeleMessage() //释放单链表{TeleNumber * temp; while(Head->Next!=End) { temp=Head->Next; Head=Head->Next; delete temp; } delete Head,End; //删除头尾指针}void TeleMessage::Save() //保存文件{out.open("TeleNumber.txt"); //建立外存文件TeleNumber.txt for(TeleNumber *p=Head->Next;p!=End;p=p->Next) out<name<<"\t"<phoneNumber<<"\t"<mobileNumber<<"\t"<email<name,p1->name); strcpy(temp->email,p1->email); temp->mobileNumber=p1->mobileNumber; temp->phoneNumber=p1->phoneNumber; temp->s=p1->s; strcpy(p1->name,p2->name); strcpy(p1->email,p2->email); p1->mobileNumber=p2->mobileNumber; p1->phoneNumber=p2->phoneNumber; p1->s=p2->s; strcpy(p2->name,temp->name); strcpy(p2->email,temp->email); p2->mobileNumber=temp->mobileNumber; p2->phoneNumber=temp->phoneNumber; p2->s=temp->s; } void TeleMessage::Sort() //起泡排序{TeleNumber *p=NULL,*q=NULL; int exchange=j-1; int bound; int i; while(exchange) { bound=exchange; exchange=0; for(p=Head->Next,i=1;iNext) if(p->mobileNumber>p->Next->mobileNumber) { Swap(p,p->Next); //调用交换函数exchange=p->s; } } Show(); } void TeleMessage::Insert() //插入{End->input(); //从单链表尾部插入End->Next=new TeleNumber; End=End->Next; cout<>name; p->Next=Search(name); //先进行查找,找到所要删除的结点if(Search(name)) { temp=p->Next; p->Next=p->Next->Next; //摘链delete temp; cout<<"\t\t删除成功!"<Next;p!=End;p=p->Next) if(!strcmp(p->name,name)) { if(x==4) { p->display(); return p; } else return p; } if(x==4) cout<<"查无此人"<>name; if(Search(name)) { cout<<"\t\t已找到个人的信息,请输入新的信息!"<input(); cout<<"修改成功!"<Next;p!=End;p=p->Next) p->display(); } int main() { bool flag=true; TeleMessage tele; char name[20]; while(flag) { system("cls"); cout<<"******************** ☆ 简单个人电话号码查询系统 ☆ ********************"<>x;a switch(x) { case 0:flag=false;break; case 1:tele.Insert();break; case 2:tele.Show();break; case 3:tele.Sort();break; case 4: cout<<"请输入欲查找认得姓名"<>name; tele.Search(name);break; case 5:tele.Remove();break; case 6:tele.Change();break; case 7:tele.Save();break; } cout<<"输入任意字母返回"<>a; } return 0; }