




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
數(shù)據(jù)庫設(shè)計:班級通訊錄
一.班級通訊錄程序設(shè)計(C語言):#include<conio、h>
#include<stdio>h>
include<iostream>
#include<string>
include<iomanip>
include<fstream>
include<cstdlib>
usingnamespacestd;
classbook
(
public:
book();〃默認構(gòu)造函數(shù)
charinter_face();〃首頁
voidadd_person();〃添力口聯(lián)系人
voiddel_person();〃刪除聯(lián)系人
voidshow_all();〃顯示所有聯(lián)系人
voidalter();〃修改信息
voidselect();〃查詢聯(lián)系人
voidsave_new();〃保存新增加的聯(lián)系人
private:
stringname;〃姓名
stringaddress;〃地址
stringnumber;〃電話號碼
stringpost;〃郵編
stringqq;//QQ號
);
structrecord
(
bookobject;〃雙向鏈表中的數(shù)據(jù)域就是就是一個記錄類
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、添加新聯(lián)系人、4、修改信息、※“?endl
※“?endl
〈〈"'NX2、刪除聯(lián)系人、5、查詢聯(lián)系人、?endl
〈〈"'NX※“?endl
〈〈"'NX3、顯示所有聯(lián)系人、6、關(guān)閉通迅錄、※“?endl
※“?endl
?endl?endl
選擇
charchoose;
cin?choose;
fflush(stdin);
returnchoose;
)
〃添加聯(lián)系人
voidbook::add_person()
(
cout<vendlvv"根據(jù)下面提示輸入新聯(lián)系人信息"?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<<“新聯(lián)系人信息已經(jīng)保存好!!!!!"?endl?endl;
system("pause");
}
〃刪除聯(lián)系人
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<<"您想刪除的聯(lián)系人:"?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"對不起!!!聯(lián)系人中沒您找的人!!!!”?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"這個人的信息已經(jīng)從您的通迅錄中刪除!!!"?endl?endl;
}
system("pause");
}
〃顯示所有聯(lián)系人
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<<”所有聯(lián)系人信息如下:"?endl;
}
cout?record?endl;
flag=false;
}
if(flag)
(
cout<vendl您的通迅錄中沒有聯(lián)系人!!!!!”?endl?endl;
}
else
cout<vendl<v"所有聯(lián)系人已經(jīng)全部顯示出來!!!!!"?endl?endl;
)
system("pause");
)
〃修改信息
voidbook::alter()
(
ifstreaminData("pbook>txt",ios::in);
if(linData)
(
cout<vendl對不起不能打開文件!!!!!”?endl?endl;
system("pause");
return;
}
stringsign;
cout?endl<<“請輸入您想要修改的聯(lián)系人的姓名或電話號碼:";
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<<"您想修改您聯(lián)系人的信息如下:"?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請根據(jù)下面提示修改信息:"?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<<"您的通迅錄中沒有您找的聯(lián)系人!!!!"?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信息已經(jīng)修改完成!!!!"?endl?endl;
system("pause");
}
}
〃查詢聯(lián)系人
voidbook::select()
(
ifstreaminData("pbook>txt”,ios::in);
if(linData)
(
cout<<endl<<"對不起!!!!文件找不到!!!!”?endl;
system("pause");
return;
)
stringsign;
cout<<endl<(“輸入您想查找的聯(lián)系人的姓名或電話號碼:
cin?sign;
fflush(stdin);
stringstrl;
boolflag=true;
stringstr;
while(inData?name?number)
{
getlinefinData,str);
if((name==sign)11(number==sign))
(
cout?endl<<“您要查找的聯(lián)系人就是:"?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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 快遞員工培訓(xùn)課件
- 寵物養(yǎng)殖租賃合同范本
- 金屬橋架合同范本
- 小學(xué)生食品安全課件
- 高低壓配電工程施工承包合同
- 檢驗滅火器合同書
- 關(guān)于采購辦公用品的申請報告與審批流程說明
- 民族局離婚協(xié)議書
- 中學(xué)生課外閱讀指南觀后感
- 法律咨詢行業(yè)法律建議免責
- 新媒體藝術(shù)設(shè)計交互融合元宇宙
- 家長會課件:七年級家長會優(yōu)質(zhì)課件
- 《AutoCAD 中文版實例教程(AutoCAD 2020) (微課版)(第 2 版)》課件 馬連志 第1、2章 AutoCAD 2020 中文版入門、繪圖設(shè)置
- 小學(xué)一年級硬筆書法入門班教學(xué)課件
- 第三方檢查應(yīng)對措施方案
- 2020年財產(chǎn)保險公司部門職責和崗位說明書
- TBA19利樂灌裝機操作手冊
- 人力資源管理咨詢實務(wù)人力資源總監(jiān)手冊
- ESC指導(dǎo)心包疾病最全
- (完整版)建筑模型設(shè)計與制作
- 08SS523建筑小區(qū)塑料排水檢查井
評論
0/150
提交評論