




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
數據庫設計:班級通訊錄
一.班級通訊錄程序設計(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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 高性能氫燃料電池測試工程師崗位聘用合同
- 抖音短視頻內容違約金計算及責任界定合同
- 環保產業投資風控完善補充協議
- 紡織服裝企業股權分割與品牌合作協議
- 煤炭安全生產責任與經營管理委托協議
- 撕毀合約機協議書
- 夢見捐器官協議書
- 找工人拆墻協議書
- 無責任傷殘協議書
- 歐洲城市公寓托管租賃全權委托合同
- 員工個人勞務合同電子版
- 五年級口算1000題(打印版)
- 五官科護理第七章-口腔頜面部的應用解剖生理課件
- 第四章 第二節招聘
- FZT 73013-2017 針織泳裝行業標準
- 科技志愿服務培訓課件
- 血液科疾病常見癥狀護理培訓課件
- 2024-2025年全國初中化學競賽試卷及答案
- 2024年首都機場集團資產管理有限公司招聘筆試參考題庫含答案解析
- 生產異常管理課件
- 酒廠擴建可行性報告
評論
0/150
提交評論