




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、數(shù)據(jù)庫(kù)設(shè)計(jì):班級(jí)通訊錄一班級(jí)通訊錄程序設(shè)計(jì)(C語(yǔ)言):#include<conio.h> #include<stdio.h> #include <iostream>#include <string>#include <iomanip>#include <fstream>#include <cstdlib>using namespace std;class bookpublic: book();/默認(rèn)構(gòu)造函數(shù) char inter_face();/首頁(yè) void add_person();/添加聯(lián)系人 void
2、del_person();/刪除聯(lián)系人 void show_all();/顯示所有聯(lián)系人 void alter();/修改信息 void select();/查詢(xún)聯(lián)系人 void save_new();/保存新增加的聯(lián)系人private: string name;/姓名 string address;/地址 string number;/電話(huà)號(hào)碼 string post;/郵編 string qq;/QQ號(hào);struct record book object;/雙向鏈表中的數(shù)據(jù)域是是一個(gè)記錄類(lèi) record *prior;/指向前軀 record *next;/指向后繼;book:book()
3、 name = "0" address = "0" number = "0" post = "0" qq = "0"/首頁(yè)char book:inter_face() system("cls"); cout <<endl; cout<<"tt" <<endl <<"tt " <<endl <<"tt 班 級(jí) 通 迅 錄 " <<end
4、l <<"tt " <<endl <<"tt 1. 添加新聯(lián)系人. 4. 修改信息. " <<endl <<"tt " <<endl <<"tt 2. 刪除聯(lián)系人. 5. 查詢(xún)聯(lián)系人. " <<endl <<"tt " <<endl <<"tt 3. 顯示所有聯(lián)系人. 6. 關(guān)閉通迅錄. " <<endl <<"
5、tt " <<endl <<"tt" <<endl <<endl <<"ttt選擇 :" ; char choose; cin >>choose; fflush(stdin); return choose;/添加聯(lián)系人void book:add_person() cout <<endl <<"根據(jù)下面提示輸入新聯(lián)系人信息" <<endl <<endl <<"姓名 :" ; c
6、in >>name; fflush(stdin); cout <<"電話(huà) : " cin >>number; fflush(stdin); cout <<"QQ : " cin >>qq; fflush(stdin); cout <<"郵編 : " cin >>post; fflush(stdin); cout <<"地址 : " cin >>address; fflush(stdin); save_new(
7、); cout <<endl <<endl <<"新聯(lián)系人信息已經(jīng)保存好!" <<endl <<endl; system("pause");/刪除聯(lián)系人void book:del_person() ofstream outData("temp.txt", ios:out); ifstream inData("pbook.txt", ios:in); if (!outData | !inData) cout <<endl <<&quo
8、t;對(duì)不起!找不到文件!" <<endl; system("pause"); return; string sign; cout <<endl <<"你要?jiǎng)h除輸入姓名或電話(huà)號(hào) :" cin >>sign; string str1; bool flag = true; string str; while (inData >>name >>number) getline(inData, str); if (sign=name) | (sign=number) cout <
9、<endl <<"你想刪除的聯(lián)系人:" <<endl <<endl; cout <<str1 <<endl; cout <<setiosflags(ios:left) <<setw(17) <<name <<" " <<number <<str <<endl; flag = false; break; outData <<setiosflags(ios:left) <<setw(17
10、) <<name <<" " <<number <<str <<endl; if (flag) cout <<endl <<"對(duì)不起!聯(lián)系人中沒(méi)你找的人!" <<endl <<endl; else while (getline(inData, str) outData <<str <<endl; outData.close(); inData.close(); ofstream out("pbook.txt&quo
11、t;, ios:out); ifstream in("temp.txt", ios:in); if (!out | !in) cout <<endl <<"對(duì)不起不能打開(kāi)文件!" <<endl <<endl; system("pause"); return; while (getline(in, str) out <<str <<endl; out.close(); in.close(); cout <<endl <<"這個(gè)人的信
12、息已經(jīng)從你的通迅錄中刪除!" <<endl <<endl; system("pause"); /顯示所有聯(lián)系人void book:show_all() ifstream inData("pbook.txt",ios:in); if (!inData) cout <<endl <<"對(duì)不起!沒(méi)有找到文件!" <<endl; system("pause"); return; bool flag = true; string record; while
13、 (getline(inData, record) if (flag) cout <<endl <<"所有聯(lián)系人信息如下: "<<endl; cout <<record <<endl; flag = false; if (flag) cout <<endl <<"你的通迅錄中沒(méi)有聯(lián)系人!" <<endl <<endl; else cout <<endl <<"所有聯(lián)系人已經(jīng)全部顯示出來(lái)!" <<
14、;endl <<endl; system("pause");/修改信息void book:alter() ifstream inData("pbook.txt", ios:in); if (!inData) cout <<endl <<"對(duì)不起不能打開(kāi)文件!" <<endl <<endl; system("pause"); return; string sign; cout <<endl <<"請(qǐng)輸入你想要修改的聯(lián)系人的姓
15、名或電話(huà)號(hào)碼 :" cin >>sign; fflush(stdin); string str1; getline(inData, str1); record *H = new record; record *p = H; record *q = H; bool flag = true; while (inData >>p-> >>p->object.number >>p->object.qq >>p->object.post >>p->object.addre
16、ss) p->next = new record; p = p->next; p->prior = q; q->next = p; q = p; p->next = NULL; inData.close(); p = H; while (p) if (p->=sign) | (p->object.number=sign) if (flag) cout <<endl <<"你想修改你聯(lián)系人的信息如下: " <<endl <<endl; cout <<en
17、dl <<str1 <<endl; cout <<setiosflags(ios:left) <<setw(17) <<p-> <<" " <<setw(16) <<p->object.number <<" " <<setw(18) <<p->object.qq <<" " <<setw(14) <<p->object.po
18、st <<" " <<setw(20) <<p->object.address <<endl; flag = false; cout <<endl <<"請(qǐng)根據(jù)下面提示修改信息 : " <<endl; cout <<"姓名 :" ; cin >>p->; fflush(stdin); cout <<"電話(huà)號(hào):" cin >>p->object.n
19、umber; fflush(stdin); cout <<"QQ :" cin >>p->object.qq; fflush(stdin); cout <<"郵編 :" cin >>p->object.post; fflush(stdin); cout <<"地址 :" cin >>p->object.address; fflush(stdin); break; p = p->next; if (flag) cout <<end
20、l <<"你的通迅錄中沒(méi)有你找的聯(lián)系人!" <<endl <<endl; system("pause"); return; else ofstream out("pbook.txt",ios:out); if (!out) cout <<endl <<"對(duì)不起!不能打開(kāi)文件!" <<endl; system("pause"); return; out <<str1 <<endl; p = H->
21、next; while (p) out <<setiosflags(ios:left) <<setw(17) <<p-> <<" " <<setw(16) <<p->object.number <<" " <<setw(18) <<p->object.qq <<" " <<setw(14) <<p->object.post <<&quo
22、t; " <<setw(20) <<p->object.address <<endl; p = p->next; out.close(); cout <<endl <<"信息已經(jīng)修改完成!" <<endl <<endl; system("pause"); /查詢(xún)聯(lián)系人void book:select() ifstream inData("pbook.txt",ios:in); if (!inData) cout <<e
23、ndl <<"對(duì)不起!文件找不到!" <<endl; system("pause"); return; string sign; cout <<endl <<"輸入你想查找的聯(lián)系人的姓名或電話(huà)號(hào)碼: " cin >>sign; fflush(stdin); string str1; bool flag = true; string str; while (inData >>name >>number) getline(inData, str); if
24、(name=sign) | (number=sign) cout <<endl <<"你要查找的聯(lián)系人是: " <<endl <<endl; cout <<str1 <<endl; cout <<setiosflags(ios:left) <<setw(17) <<name <<number <<str <<endl; flag = false; break; void book:save_new() ofstream outData("pbook.txt", ios:app); if (!outData) cout <<endl <<"對(duì)不起!打開(kāi)文件失敗!" <<endl <<endl; system("pause"); return; outData << setiosflags(ios:left) << setw(17) << name <<" " << setw(16) <<
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年甘肅交通職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫(kù)完美版
- 2025年度學(xué)生安全教育與心理健康維護(hù)合同
- 2025年度勞動(dòng)合同解除補(bǔ)償協(xié)議及員工福利待遇保障書(shū)
- 2025年度保險(xiǎn)公司與國(guó)有企業(yè)單位全面合作協(xié)議
- 2025年度房屋租賃合同訂金及配套設(shè)施使用協(xié)議
- 2025年度摩托車(chē)進(jìn)出口代理業(yè)務(wù)合同
- 2025年度公司股東內(nèi)部關(guān)于股權(quán)結(jié)構(gòu)優(yōu)化與分配的協(xié)議書(shū)
- 2025年度委托招聘合同-行業(yè)領(lǐng)軍人才合作項(xiàng)目
- 2025年度員工向公司借款合同變更通知合同
- 2025年度工程車(chē)輛司機(jī)勞務(wù)派遣合同
- 2024年1月浙江高考英語(yǔ)聽(tīng)力考試試題真題完整版答案詳解+MP3文本
- 《SolidWorks建模實(shí)例教程》第5章 裝配建模及實(shí)例
- 口腔科護(hù)理教學(xué)查房
- 《趙匡胤:北宋的開(kāi)國(guó)皇帝》
- 二年級(jí) 書(shū)法 開(kāi)學(xué)第一課課
- 精神科病人跌倒的預(yù)防與處理
- 蒸壓加氣混凝土砌塊干燥收縮檢測(cè)記錄11969-2020
- 2023-2024學(xué)年第二學(xué)期人教版英語(yǔ)五年級(jí)教學(xué)計(jì)劃(含進(jìn)度表)
- 小學(xué)教師師德師風(fēng)培訓(xùn)內(nèi)容(4篇)
- (完整word版)勞動(dòng)合同書(shū)(電子版)正規(guī)范本(通用版)
- DB1522-T 1-2023 農(nóng)用天氣預(yù)報(bào) 水稻適宜度
評(píng)論
0/150
提交評(píng)論