// list.cpp: implementation of the list class.
//
//////////////////////////////////////////////////////////////////////
#include "list.h"
#include <iostream>
#include "string.h"
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern listnode* head;
extern listnode* rear;
list::list()
{
}
list::~list()
{
}
int list::menu_select()
{
int sn;
cout<<"***通讯录管理系统******\n";
cout<<"***********************\n";
cout<<" 1 通讯录建立\n";
cout<<" 2 通讯者插入\n";
cout<<" 3 通讯者删除\n";
cout<<" 4 通讯者查询\n";
cout<<" 5 通讯录输出\n";
cout<<" 0 退出 系统\n";
cout<<"***********************\n";
cout<<" 请选择 0--5:\n";
for(;;)
{
cin>>sn;
if(sn>5||sn<0)
cout<<"输入错误 请重新输入:";
else
break;
}
return sn;
}
void list::CreateList()
{
head=new listnode;
listnode* p;
char flag='y';
rear=head;
while(flag=='y')
{
p=new listnode;
cout<<"请输入 编号[4] 姓名[8] 性别 电话[11] 地址[31]\n";
cin>>p->data.num>>p->data.name>>p->data.sex>>p->data.phone>>p->data.addr;
rear->next=p;
rear=p;
cout<<"继续输入吗?(y/n)";
cin>>flag;
}
rear->next=NULL;
}
void list::insertnode()
{
listnode *p,*q,*in;
in=new listnode;
cout<<"输入要插入结点的信息:\n";
cout<<"请输入 编号[4] 姓名[8] 性别 电话[11] 地址[31]\n";
cin>>in->data.num>>in->data.name>>in->data.sex>>in->data.phone>>in->data.addr;
p=head;
q=p->next;
while(q&&p->data.num<in->data.num)
{
p=q;
q=q->next;
}
p->next=in;
in->next=q;
}
listnode * list::listfind()
{
listnode *p;
char num[5];
char name[9];
int xz;
cout<<"*********************\n";
cout<<" 1 按编号查找 \n";
cout<<" 2 按姓名查找 \n";
cout<<"*********************\n";
cout<<"请选择:";
p=head->next;
cin>>xz;
if(xz==1)
{
cout<<"请输入要查找者的编号:\n";
cin>>num;
while(p&&p->data.num<num)
p=p->next;
if(p==NULL||p->data.num>num)
p=NULL;
}
else if(xz==2)
{
cout<<" 请输入要查找的人的姓名:\n";
cin>>name;
while(p&&strcmp(p->data.name,name)!=0)
p=p->next;
}
cout<<p->data.num<<" "<<p->data.name<<" "<<p->data.sex<<" "<<p->data.phone<<" "<<p->data.addr<<endl;
return p;
}
void list::delnode()
{
listnode *p,*q;
p=listfind();
if(p==NULL)
{
cout<<"没找到要删除的结点;\n";
return;
}
q=head;
while(q!=NULL&&q->next!=p)
q=q->next;
q->next=p->next;
delete p;
}
void list::printlist()
{
listnode *p;
p=head->next;
cout<<" 编号 姓名 性别 电话 地址 \n";
cout<<"****************************************\n";
while(p!=NULL)
{
cout<<p->data.num<<" "<<p->data.name<<" "<<p->data.sex<<" "<<p->data.phone<<" "<<p->data.addr<<endl;
cout<<"****************************************\n";
p=p->next;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
C++版数据结构课程设计-----通讯录管理
共23个文件
pdb:3个
manifest:2个
cpp:2个
需积分: 9 84 下载量 42 浏览量
2008-06-16
17:11:45
上传
评论 5
收藏 973KB RAR 举报
温馨提示
C++版数据结构课程设计-----通讯录管理,比较号的学习资料,分享了~~~
资源推荐
资源详情
资源评论
收起资源包目录
通讯录管理.rar (23个子文件)
通讯录管理
main.cpp 639B
hw21.ncb 2.05MB
hw21.dsp 4KB
hw21.suo 10KB
hw21.sln 873B
hw21.opt 48KB
list.cpp 3KB
hw21.vcproj.SUNSHINE.Administrator.user 1KB
hw21.vcproj 5KB
hw21.dsw 516B
Debug
hw21.pdb 2.45MB
vc60.pdb 60KB
hw21.exe.embed.manifest 406B
BuildLog.htm 6KB
mt.dep 67B
main.obj 116KB
list.obj 339KB
vc90.pdb 180KB
hw21.exe.embed.manifest.res 472B
hw21.exe.intermediate.manifest 381B
hw21.exe 454KB
hw21.plg 242B
list.h 785B
共 23 条
- 1
资源评论
cl490653766
- 粉丝: 9
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功