单链表实现个人通讯录管理助手

通过调试,能够运行成功



#include
#include
#include
using namespace std;

struct Phone
{
 char name[10];            //姓名
 char number[12];         //电话号码
 char add[30];           //住址
 char post[20];         //邮编
 int age;              //年龄
 char sex[2];         //性别
 char QQ[11];        //QQ
 char weixin[11];   //微信
 char birth[20];   //生日
 struct Phone *next;
};

typedef struct Phone Node;
typedef Node *pNode;

void Check(pNode pHead)
{
 pNode ptr;
 ptr=pHead;
 char ckName[10];
 cout<<"请输入您要查询人的姓名:"<>ckName;
 while (ptr)
 {
  if (strcmp(ptr->name,ckName)==0)//strcmp是比较两个字符串是否相等
  {
   cout<<"您要查询的人的号码是:"<number<next;
   cout<<"您要查询的人的号码不存在!"<>newnode->name;
 cout<<"电话号码:";
 cin>>newnode->number;
  cout<<"地址:";
 cin>>newnode->add;
  cout<<"邮编:";
 cin>>newnode->post;
  cout<<"年龄:";
 cin>>newnode->age;
  cout<<"性别:";
 cin>>newnode->sex;
  cout<<"QQ:";
 cin>>newnode->QQ;
  cout<<"微信:";
 cin>>newnode->weixin;
   cout<<"生日:";
 cin>>newnode->birth;

 if (pHead)
 {
  ptr=pHead;
  while (ptr->next)
  {
   ptr=ptr->next;
  }
  newnode->next=NULL;
  ptr->next=newnode;
 }
 else
 {
  newnode->next=pHead;
  pHead=newnode;
  ptr=pHead;
 }
 cout<<"添加成功!"<name<<"\n";
  cout<<"电话:"<number<<"\n";
  cout<<"地址:"<add;
  cout<<"\n"<<"邮编:"<post<<"\n";
  cout<<"年龄:"<age<<"\n";
  cout<<"性别:"<sex;
  cout<<"\n"<<"QQ  :"<QQ<<"\n";
  cout<<"微信:"<weixin<<"\n";
  cout<<"生日:"<birth<next;
 }
}

void DeleteItem(pNode &pHead)
{
 pNode ptr,pBefore;
 ptr=pBefore=pHead;
 char ckName[10];
 cout<<"请输入您要删除人的姓名:"<>ckName;
    while (ptr!=NULL)
    {
  if (strcmp(ptr->name,ckName)==0)
  {
   break;
  }
  else
  {
   pBefore=ptr;
   ptr=ptr->next;
  }
    }

 if (ptr)
 {
  if (ptr==pHead)
  {
   pHead=ptr->next;
   delete ptr;
  }
  else
  {
   pBefore->next=ptr->next;
   delete ptr;
  }
  cout<<"删除成功!"<>user;
    cout<<" 请输入管理员密码:";
  cin>>password;
  if(strcmp(user,"12345")==0&&strcmp(password,"12345")==0)
   {

    cout< 添加信息                  |"< 查看信息                  |"< 查询信息                  |"< 删除信息                  |"< 退出                      |"<>iChoice)
 {
  switch (iChoice)
  {
  case 1:
   AddNewItem(pHead);//添加记录
   break;
  case 2:
   cout<<"您要查看的记录有:"< 添加信息                  |"< 查看信息                  |"< 查询信息                  |"< 删除信息                  |"< 退出                      |"<


你可能感兴趣的:(数据结构)