数据库设计作业_第1页
数据库设计作业_第2页
数据库设计作业_第3页
数据库设计作业_第4页
数据库设计作业_第5页
已阅读5页,还剩5页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

数据库设计:班级通讯录

一.班级通讯录程序设计(C语言):#include<conio、h>

#include<stdio>h>

include<iostream>

#include<string>

include<iomanip>

include<fstream>

include<cstdlib>

usingnamespacestd;

classbook

(

public:

book();〃默认构造函数

charinter_face();〃首页

voidadd_person();〃添力口联系人

voiddel_person();〃删除联系人

voidshow_all();〃显示所有联系人

voidalter();〃修改信息

voidselect();〃查询联系人

voidsave_new();〃保存新增加的联系人

private:

stringname;〃姓名

stringaddress;〃地址

stringnumber;〃电话号码

stringpost;〃邮编

stringqq;//QQ号

);

structrecord

(

bookobject;〃双向链表中的数据域就是就是一个记录类

record*prior;〃指向前躯

record*next;〃指向后继

);

book::book()

{

name="\0";

address="\0";

number="\0";

post="\0";

qq="\0";

)

〃首页

charbook::inter_face()

(

system("cls");

cout«endl;

※“«endl

班级通迅录※“«endl

〈〈"'NX※“«endl

〈〈"'NX1、添加新联系人、4、修改信息、※“«endl

※“«endl

〈〈"'NX2、删除联系人、5、查询联系人、«endl

〈〈"'NX※“«endl

〈〈"'NX3、显示所有联系人、6、关闭通迅录、※“«endl

※“«endl

«endl«endl

选择

charchoose;

cin»choose;

fflush(stdin);

returnchoose;

)

〃添加联系人

voidbook::add_person()

(

cout<vendlvv"根据下面提示输入新联系人信息"«endl«endl

姓名:";

cin»name;

fflush(stdin);

coutvv"电话:”;

cin»number;

fflush(stdin);

cout«"QQ:

cin»qq;

fflush(stdin);

coutvv”邮编:”;

cin»post;

fflush(stdin);

cout<<"地址:

cin»address;

fflush(stdin);

save_new();

cout«endl«endl<<“新联系人信息已经保存好!!!!!"«endl«endl;

system("pause");

}

〃删除联系人

voidbook::del_person()

(

ofstreamoutData("temp>txt",ios::out);

ifstreaminData("pbook>txt",ios::in);

if(loutData11iinData)

(

cout<<endl<<”对不起!!!!找不到文件!!!!”«endl;

system("pause");

return;

)

stringsign;

cout<<endl<<"您要删除输入姓名或电话号:";

cin»sign;

stringstrl;

boolflag=true;

stringstr;

while(inData»name»number)

(

getlinefinData,str);

if((sign==name)11(sign==number))

(

cout«endl<<"您想删除的联系人:"«endl«endl;

cout«strl«endl;

cout«setiosflags(ios::left)«setw(17)«name

«""«number«str«endl;

flag=false;

break;

}

outData«setiosflags(ios::left)«setw(17)«name

«""«number«str«endl;

}

if(flag)

(

cout<<endl<v"对不起!!!联系人中没您找的人!!!!”«endl«endl;

)

else

(

while(getline(inData,str))

(

outData«str«endl;

}

outData>close();

inData、close();

ofstreamout("pbook>txt",ios::out);

ifstreamin("temp>txt",ios::in);

if(lout11!in)

(

cout«endl对不起不能打开文件!!!"«endl«endl;

system("pause");

return;

}

while(getline(in,str))

(

out«str«endl;

}

out、close();

in、close();

cout<<endlvv"这个人的信息已经从您的通迅录中删除!!!"«endl«endl;

}

system("pause");

}

〃显示所有联系人

voidbook::show_all()

(

ifstreaminData("pbook>txf'Jos-in);

if(linData)

(

cout<<endl<<"对不起!!!!没有找到文件!!!!!”«endl;

system("pause");

return;

}

boolflag=true;

stringrecord;

while(getline(inData,record))

(

if(flag)

(

cout<<endl<<”所有联系人信息如下:"«endl;

}

cout«record«endl;

flag=false;

}

if(flag)

(

cout<vendl您的通迅录中没有联系人!!!!!”«endl«endl;

}

else

cout<vendl<v"所有联系人已经全部显示出来!!!!!"«endl«endl;

)

system("pause");

)

〃修改信息

voidbook::alter()

(

ifstreaminData("pbook>txt",ios::in);

if(linData)

(

cout<vendl对不起不能打开文件!!!!!”«endl«endl;

system("pause");

return;

}

stringsign;

cout«endl<<“请输入您想要修改的联系人的姓名或电话号码:";

cin»sign;

fflush(stdin);

stringstrl;

getlinefinData,strl);

record*H=newrecord;

record*p=H;

record*q=H;

boolflag=true;

while(inData»p->object>name»p->object>number»p->object>qq

»p->object>post»p->object>address)

(

p->next=newrecord;

p=p->next;

p->prior=q;

q->next=p;

q=p;

)

p->next=NULL;

inData、close();

P=H;

while(p)

(

if((p->object>name==sign)11(p>>object>number二二sign))

(

if(flag)

cout<<endl<<"您想修改您联系人的信息如下:"«endl«endl;

cout«endl«strl«endl;

cout«setiosflags(ios::left)«setw(17)

<<p->object、name«""«setw(16)«p->object>number

«""«setw(18)«p->object>qq

«""«setw(14)«p->object>post

«""«setw(20)«p->object>address«endl;

flag=false;

)

cout«endl请根据下面提示修改信息:"«endl;

coutvv“姓名:”;

cin»p->object>name;

fflush(stdin);

cout«"电话号:";

cin»p->object>number;

fflush(stdin);

cout«"QQ

cin»p->object>qq;

fflush(stdin);

coutvv"邮编

cin»p->object>post;

fflush(stdin);

cout«”地址

cin»p->object>address;

fflush(stdin);

break;

}

p=p->next;

)

if(flag)

(

cout<<endl<<"您的通迅录中没有您找的联系人!!!!"«endl«endl;

system("pause");

return;

)

else

(

ofstreamout("pbook>txt"zios::out);

if(lout)

(

cout<<endl对不起!!!不能打开文件!!!!”«endl;

system("pause");

return;

)

out«strl«endl;

p=H->next;

while(p)

out«setiosflags(ios::left)«setw(17)«p->object>name

«""«setw(16)«p->object>number

«""«setw(18)«p->object>qq

«""«setw(14)«p->object>post

«""«setw(20)«p->object>address«endl;

p=p->next;

)

out、close();

coutvvendl信息已经修改完成!!!!"«endl«endl;

system("pause");

}

}

〃查询联系人

voidbook::select()

(

ifstreaminData("pbook>txt”,ios::in);

if(linData)

(

cout<<endl<<"对不起!!!!文件找不到!!!!”«endl;

system("pause");

return;

)

stringsign;

cout<<endl<(“输入您想查找的联系人的姓名或电话号码:

cin»sign;

fflush(stdin);

stringstrl;

boolflag=true;

stringstr;

while(inData»name»number)

{

getlinefinData,str);

if((name==sign)11(number==sign))

(

cout«endl<<“您要查找的联系人就是:"«endl«endl;

cout«strl«endl;

cout«setiosflags(ios::left)«setw(17)«name

«number«str«endl;

flag=false;

break;

)

)

)

voidbook::save_new()

(

ofstreamoutData("pbook>txt",ios::app);

if(loutData)

(

cout<<endl<<”对不起!!!打开文件失败!!!!”«endl«endl;

system("pause");

return;

)

outData«setiosflags(ios::left)«setw(17)«name

«""«setw(16)«number«""

«setw(18)«qq«""

«setw(14)«post«""

«setw(20)«address«endl;

outData>close();

)

enumpower{ADD='1',DEL='2;SHOW='3',Alter='4',Select='5',END='6'};

intmain()

(

charch

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论