Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2341003
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:08:42

#include
#include
#include
#include
typedef struct node
{  char n[20];//姓名
   char sex[5];
   char tel[10];
   char ID[20];
   char addr[35];
   struct node *next;
}NODE;

  class employee
  {
  private:
  NODE *p;
  NODE *q;
  NODE *t;
  public:
  employee(NODE *m);
  void add();
  void printall();
  void print();
  void deleteall();
  void edit();
  void del();
  };
  employee::employee(NODE *m)
  { t=p=m;
  }
  void employee::del()
 { NODE *k;
  k=new NODE;
  k=p=q;
  char wid[20];
  cout<<"请输入同学姓名:"<  cin>>wid;
  while (p!=t&&(strcmp(p->n,wid)!=0)!=0)
    {k=p;
    p=p->next;
     }
   if (p==t)
     {cout<<"查无此人!!"<     }
  else
    {if (p==q)
    q=q->next;
    else
     k->next=p->next;
     free(p);
    }
  }  
  void employee::print()                                        
  { p=q;
  char wid[20];
  cout<<"请输入同学姓名:"<  cin>>wid;
  while (p!=t&&(strcmp(p->n,wid)!=0)!=0)
    {p=p->next;
     }
   if (p==t)
     {cout<<"查无此人!!"<     }
  else
    { cout<<"姓名:"<n<  cout<<"性别:"<sex<  cout<<"家庭电话:"<tel<  cout<<"身份证号:"<ID<  cout<<"家庭住址:"<addr<    }
  cout<<"按任意键返回!!"<   }
  void employee::edit()
 {
  p=q;
  char wid[20];
  cout<<"请输入同学姓名:"<  cin>>wid;
  while (p!=t&&(strcmp(p->n,wid)!=0)!=0)
    {p=p->next;
     }
   if (p==t)
     {cout<<"查无此人!!"<     }
 else
 {cout<<"姓名";
  cin>>p->n;
  cout<<"性别:";
  cin>>p->sex;
  cout<<"家庭电话:";
  cin>>p->tel;
  cout<<"身份证号:";
  cin>>p->ID;
 }
  cout<<"按任意键返回!!"<  }
  void employee::add()
 {
  q= new NODE;
  q->next=p;
  p=q;
  cout<<"姓名:";
  cin>>q->n;
  cout<<"性别:";
  cin>>q->sex;
  cout<<"家庭电话:";
  cin>>q->tel;
  cout<<"身份证号:";
  cin>>q->ID;
  cout<<"家庭住址:";
  cin>>q->addr;
  cout<<"按任意键返回!!"< 
}
void employee::printall()
{
  p=q;
 while (q!=t)
  {
  cout<<"姓名:"<n<  cout<<"性别:"<sex<  cout<<"家庭电话:"<tel<  cout<<"身份证号:"<ID< 
cout<<"家庭住址:"<addr<  q=q->next;
 // getch();
 }
  q=p;
}
void employee::deleteall()
{

while (q!=t)
 {p=q;
 q=q->next;
 free(p);
 }
cout<<"所有信息已删除!" ;
}

 void display()
{  
cout<<"\n              **************计科04-1班通讯录管理系统*************"< 
cout<<"   __________________________________________________________________________ "<cout<<"  |                                                                          |"<cout<<"  |                        1:增加一个新成员!                                |"<cout<<"  |                                                                          |"<cout<<"  |                        2:修改成员信息!                                  |"<cout<<"  |                                                                          |"<cout<<"  |                        3:查找成员信息!                                  |"<cout<<"  |                                                                          |"<cout<<"  |                        4:显示所有成员信息!                              |"<cout<<"  |                                                                          |"<cout<<"  |                        5:删除成员信息!                                  |"<cout<<"  |                                                                          |"<cout<<"  |                        6:删除所有成员信息!                              |"<cout<<"  |                                                                          |"<cout<<"  |                        7:退出!                                          |"<cout<<"  |__________________________________________________________________________|"<}
  void main()                      
 {
  NODE *pa;
  char i;
  pa=(NODE*)malloc(sizeof(struct node));
  d

--------------------next---------------------

阅读(1220) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~