數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)(學(xué)生信息管理系統(tǒng))_第1頁(yè)
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)(學(xué)生信息管理系統(tǒng))_第2頁(yè)
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)(學(xué)生信息管理系統(tǒng))_第3頁(yè)
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)(學(xué)生信息管理系統(tǒng))_第4頁(yè)
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)(學(xué)生信息管理系統(tǒng))_第5頁(yè)
已閱讀5頁(yè),還剩20頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、 學(xué)生通訊錄管理系統(tǒng)設(shè)計(jì)1 需求分析1.1 設(shè)計(jì)任務(wù)要求通訊錄系統(tǒng)主要包含以下要求:(1)設(shè)計(jì)一個(gè)學(xué)生通訊錄管理系統(tǒng),每個(gè)學(xué)生數(shù)據(jù)信息包括:姓名、電話號(hào)碼、qq、郵編和地址;(2)創(chuàng)建學(xué)生數(shù)據(jù)類(lèi)型為結(jié)構(gòu)體并以磁盤(pán)文件保存;(3)能讀取磁盤(pán)文件并顯示輸出學(xué)生的相關(guān)信息;(4)能按姓名或電話等多種方式進(jìn)行學(xué)生信息查詢;(5)能查詢、添加、修改和刪除學(xué)生通訊錄。1.2 系統(tǒng)功能需求分析系統(tǒng)主要包含以下主要功能:(1)查詢通訊錄記錄;(2)添加通訊錄記錄;(3)修改通訊錄記錄;(4)刪除通訊錄記錄;(5)關(guān)閉通訊錄。2 概要設(shè)計(jì)2.1 數(shù)據(jù)類(lèi)型本系統(tǒng)中所有變量都定義為字符串型,學(xué)生通訊錄數(shù)據(jù)類(lèi)型定義為

2、結(jié)構(gòu)體類(lèi)型。然而為了更加方便,添加了抽象數(shù)據(jù)類(lèi)型類(lèi)book,再私有繼承了以結(jié)構(gòu)體存儲(chǔ)的學(xué)生數(shù)據(jù)。2.2 主程序及各程序?qū)哟侮P(guān)系以下是系統(tǒng)功能模塊關(guān)系圖,主要包含查詢、添加、修改、刪除聯(lián)系人和關(guān)閉系統(tǒng)等功能。另外還提供了鍵盤(pán)式選擇菜單實(shí)現(xiàn)功能選擇。圖2.1 系統(tǒng)功能模塊關(guān)系圖查詢聯(lián)系人:可以選擇用姓名和電話兩種方式查詢添加聯(lián)系人:可以添加通訊錄記錄,依次輸入姓名、電話、qq、郵編和地址修改聯(lián)系人:輸入欲修改聯(lián)系人姓名后,再依次輸入修改姓名、電話、qq、郵編和地址即可完成修改刪除聯(lián)系人:輸入欲刪除聯(lián)系人的姓名后,會(huì)自動(dòng)刪除該聯(lián)系人的記錄內(nèi)容關(guān)閉系統(tǒng):選擇相關(guān)操作進(jìn)行系統(tǒng)正常關(guān)閉,保存有效數(shù)據(jù)記錄3

3、 詳細(xì)設(shè)計(jì)3.1 實(shí)現(xiàn)數(shù)據(jù)類(lèi)型(1)以字符串類(lèi)型定義通訊錄中學(xué)生數(shù)據(jù)信息變量:string name;/姓名 string number;/電話號(hào)碼 string qq;/QQ號(hào) string post;/郵編 string address;/地址(2)學(xué)生通訊錄數(shù)據(jù)類(lèi)型定義為結(jié)構(gòu)體存儲(chǔ):struct inf string name;/姓名 string address;/地址 string number;/電話號(hào)碼 string post;/郵編 string qq;/QQ號(hào)datatype;(3)實(shí)現(xiàn)類(lèi)book私有繼承結(jié)構(gòu)體inf:class book:private infpublic:

4、 book();/默認(rèn)構(gòu)造函數(shù) int face();/首頁(yè) void add_person();/添加聯(lián)系人 void del_person();/刪除聯(lián)系人 void fix();/修改信息 void find();/查詢聯(lián)系人 void save_new();/保存新增加的聯(lián)系人;3.2 實(shí)現(xiàn)各操作模塊的功能(1)主函數(shù)的實(shí)現(xiàn):int main() int choose; book b; while (choose = b.face() switch (choose) case 1: b.find();/查詢聯(lián)系人 break; case 2: b.add_person();/添加聯(lián)系人

5、 break; case 3: b.fix();/修改信息 break; case 4: b.del_person();/刪除聯(lián)系人 break; case 5: cout <<endl <<"謝謝使用!" <<endl <<endl; exit(0);/退出系統(tǒng) break; default: break; return 0;(2)各操作模塊函數(shù)的實(shí)現(xiàn):void book:add_person()/添加聯(lián)系人 cout <<endl <<"請(qǐng)根據(jù)提示輸入信息" <<en

6、dl <<endl cout<<"姓名 :" ;cin >>name; cout <<"電話 : "cin >>number; cout <<"QQ : "cin >>qq; cout <<"郵編 : "cin >>post; cout <<"地址 : "cin >>address; save_new(); cout <<endl <<end

7、l <<"新聯(lián)系人信息已經(jīng)保存好!" <<endl <<endl; system("pause");/出現(xiàn)中文的顯示:按任意鍵繼續(xù)。void book:del_person()/刪除聯(lián)系人 ofstream outData("temp.txt", ios:out); ifstream inData("pbook.txt", ios:in); if (!outData | !inData) cout <<endl <<"對(duì)不起!找不到文件!&quo

8、t; <<endl; system("pause"); return; string s; cout <<endl <<"你要?jiǎng)h除輸入姓名、電話或QQ :" cin >>s; string str; bool flag = true; while (inData >>name >>number) getline(inData, str); if (s=name) | (s=number) cout <<endl <<"你想刪除的聯(lián)系人:"

9、<<endl <<endl;cout<< setiosflags(ios:left) << setw(17) << "姓名" <<" " << setw(16) << "電話號(hào)碼" <<" " << setw(18) << "QQ" <<" "<< setw(14) << "郵編" <

10、<" " << setw(20) << "地址 "<<endl; cout <<setiosflags(ios:left) <<setw(17) <<name <<" " <<number<<str <<endl<<endl; flag = false; break; outData <<setiosflags(ios:left) <<setw(17) <<nam

11、e/將不刪除的信息放到temp.txt <<" " <<number <<" "<<qq<<str <<endl; if (flag) cout <<endl <<"對(duì)不起!聯(lián)系人中沒(méi)你找的人!" <<endl <<endl; else/將temp.txt的數(shù)據(jù)復(fù)制到pbook.txt,直接覆蓋要?jiǎng)h除的信息,達(dá)到刪除效果 while (getline(inData, str) outData <<str

12、<<endl; outData.close(); inData.close(); ofstream out("pbook.txt", 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 <<s

13、tr <<endl; out.close(); in.close(); cout <<endl <<"該聯(lián)系人信息已從通迅錄中刪除!" <<endl <<endl; system("pause"); void book:fix()/修改信息 ofstream outData("temp.txt", ios:out); ifstream inData("pbook.txt", ios:in); /if (!outData | !inData) cout &l

14、t;<endl <<"對(duì)不起!找不到文件!" <<endl; system("pause"); return; string s; cout <<endl <<"你要修改輸入姓名或電話號(hào) :" cin >>s; bool flag = true; string str; while (inData >>name >>number) getline(inData, str); if (s=name) | (s=number) cout <&l

15、t;endl <<"你想修改的聯(lián)系人:" <<endl <<endl;cout<< setiosflags(ios:left) << setw(17) << "姓名" <<" " << setw(16) << "電話號(hào)碼" <<" "<< setw(18) << "QQ" <<" " <<

16、setw(14) << "郵編" <<" "<< setw(20) << "地址 "<<endl; cout <<setiosflags(ios:left) <<setw(17) <<name <<" " <<number <<str <<endl; cout <<endl <<"請(qǐng)根據(jù)下面提示修改信息 : " <<e

17、ndl; cout <<"姓名 :" ;cin >>name; cout <<"電話號(hào):"cin >>number; cout <<"QQ :"cin >>qq; cout <<"郵編 :"cin >>post; cout <<"地址 :"cin >>address; save_new(); flag = false; break; outData <<setios

18、flags(ios:left) <<setw(17) <<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(); of

19、stream out("pbook.txt", 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 &

20、lt;<endl <<"該聯(lián)系人已在通迅錄中修改!" <<endl <<endl; system("pause"); void book:find()/查詢聯(lián)系人 ifstream inData("pbook.txt",ios:in); if (!inData) cout <<endl <<"對(duì)不起!文件找不到!" <<endl; system("pause"); return; string s; cout <

21、<endl <<"輸入你想查找的聯(lián)系人的姓名、電話或QQ: " cin >>s; bool flag = true; string str; while (inData >>name >>number) getline(inData, str); if (name=s) | (number=s) cout <<endl <<"你要查找的聯(lián)系人是: " <<endl <<endl;cout<< setiosflags(ios:left) <

22、;< setw(17) << "姓名"<<" " << setw(16) << "電話號(hào)碼" <<" "<< setw(18) << "QQ" <<" "<< setw(14) << "郵編" <<" "<< setw(20) << "地址 "<<

23、;endl; cout <<setiosflags(ios:left) <<setw(17) <<name <<" "<<number<<str <<endl<<endl; flag = false; break; if(flag)cout<<endl<<"該聯(lián)系人不存在!"<<endl<<endl; system("pause");void book:save_new()ofstream f

24、("pbook.txt", ios:app); if (!f) cout <<endl <<"對(duì)不起!打開(kāi)文件失敗!" <<endl <<endl; system("pause");return; f<< setiosflags(ios:left) << setw(17) << name<<" " << setw(16) << number <<" "<<

25、; setw(18) << qq <<" "<< setw(14) << post <<" "<< setw(20) << address <<endl; f.close();4 調(diào)試分析1.在程序的調(diào)試過(guò)程中遇上了文件存儲(chǔ)數(shù)據(jù)的正確讀取錯(cuò)誤,但經(jīng)過(guò)不斷查問(wèn)和查閱相關(guān)書(shū)籍后,根據(jù)調(diào)試提示錯(cuò)誤,解決了所有錯(cuò)誤。通過(guò)文件存儲(chǔ)學(xué)生數(shù)據(jù)信息,使得讀取信息操作更加方便、省事;2.在執(zhí)行操作時(shí),是根據(jù)文件搜索算法,去獲取學(xué)生數(shù)據(jù)信息。使得在時(shí)間和空間上讀取數(shù)據(jù)都要更加快捷

26、、省事。其時(shí)間復(fù)雜度為O();3.經(jīng)過(guò)這一次的系統(tǒng)設(shè)計(jì),使我認(rèn)識(shí)到了實(shí)踐的重要性,只有實(shí)踐多了才能把知識(shí)學(xué)得好,學(xué)得牢。同時(shí)讓我對(duì)數(shù)據(jù)結(jié)構(gòu)得到了進(jìn)一步的學(xué)習(xí),以及對(duì)C+語(yǔ)言的學(xué)習(xí)得以提高,最后也大部分掌握了文件存儲(chǔ)數(shù)據(jù)的相關(guān)操作。5 用戶使用手冊(cè)1.本程序的運(yùn)行環(huán)境為WINDOWS操作系統(tǒng),運(yùn)行軟件為Microsoft Visual C+;2.運(yùn)行程序后即輸出提示信息,由于在定義變量時(shí)已將需要輸入的定義為string型變量,所以輸入時(shí)需根據(jù)提示信息按要求輸入;3運(yùn)行程序后屏幕上會(huì)出現(xiàn)通訊錄主菜單,然后根據(jù)需要選擇1-5序號(hào)的操作,輸入選定序號(hào)后,按Enter鍵,程序就會(huì)執(zhí)行相關(guān)操作。比如輸入序

27、號(hào)1,再按Enter鍵,程序就會(huì)運(yùn)行查詢聯(lián)系人的代碼操作,然后再根據(jù)提示進(jìn)行查詢工作即可;4.當(dāng)以上操作完成后,程序?qū)⑤敵觥鞍慈我怄I繼續(xù).”此時(shí),查詢聯(lián)系人工作的程序運(yùn)行完畢。6 測(cè)試數(shù)據(jù)和數(shù)據(jù)結(jié)果(1)輸入操作序號(hào):2依次輸入:wen997191620 123456 湖南長(zhǎng)沙輸出結(jié)果如下所示:(2)輸入操作序號(hào):1輸入姓名:wen;(或電話號(hào)碼輸出結(jié)果如下所示:(3)輸入操作序號(hào):3輸入姓名:wen重新依次輸入要修改信息:wen997191620 654321 海南萬(wàn)寧輸出結(jié)果如下所示:(4)輸入操作序號(hào):4輸入姓

28、名:wen輸出結(jié)果如下所示:(5)輸入操作序號(hào):5輸出結(jié)果如下所示:參考文獻(xiàn)1 嚴(yán)蔚敏,吳偉民. 數(shù)據(jù)結(jié)構(gòu)(C語(yǔ)言版). 北京:清華大學(xué)出版社,1997.042 張曉莉,羅文劼,劉振鵬等。數(shù)據(jù)結(jié)構(gòu)與算法。北京:機(jī)械工業(yè)出版社,2002.103 王宏生,宋繼紅。數(shù)據(jù)結(jié)構(gòu)。北京:國(guó)防工業(yè)出版社,2006.014 孫淑霞,肖陽(yáng)春,魏琴等.C/C+程序設(shè)計(jì)教程(第2版)。北京:電子工業(yè)出版社,2007.035 譚浩強(qiáng)。C+程序設(shè)計(jì)。北京:清華大學(xué)出版社,2004,06附錄 源程序清單#include <iostream>#include <string>#include <

29、;iomanip>#include <fstream>#include <cstdlib>using namespace std;struct inf string name;/姓名 string address;/地址 string number;/電話號(hào)碼 string post;/郵編 string qq;/QQ號(hào)datatype;class book:private infpublic: book();/默認(rèn)構(gòu)造函數(shù) int face();/首頁(yè) void add_person();/添加聯(lián)系人 void del_person();/刪除聯(lián)系人 void

30、fix();/修改信息 void find();/查詢聯(lián)系人 void save_new();/保存新增加的聯(lián)系人;/首頁(yè)int book:face()system("cls");/清楚屏幕 cout <<endl<<endl; cout<<" *" <<endl <<" # #" <<endl <<" # 通 迅 錄 #" <<endl <<" # #" <<endl <

31、;<" # 1. 查詢聯(lián)系人. #" <<endl <<" # #" <<endl <<" # 2. 添加新聯(lián)系人. #" <<endl <<" # #" <<endl <<" # 3. 修改聯(lián)系人. #" <<endl <<" # #" <<endl <<" # 4. 刪除聯(lián)系人. #" <<e

32、ndl <<" # #" <<endl <<" # 5. 關(guān)閉系統(tǒng). #" <<endl <<" # #" <<endl <<" *" <<endl <<endl <<" 請(qǐng)選擇您要操作的序號(hào)(1-5) :" ; int choose; cin >>choose; return choose;/添加聯(lián)系人void book:add_person() cout <

33、;<endl <<"請(qǐng)根據(jù)提示輸入信息" <<endl <<endl <<"姓名 :" ; cin >>name; cout <<"電話 : " cin >>number; cout <<"QQ : " cin >>qq; cout <<"郵編 : " cin >>post; cout <<"地址 : " cin >>

34、;address; save_new(); cout <<endl <<endl <<"新聯(lián)系人信息已經(jīng)保存好!" <<endl <<endl; system("pause");/出現(xiàn)中文的顯示:按任意鍵繼續(xù)。/刪除聯(lián)系人void book:del_person() ofstream outData("temp.txt", ios:out); ifstream inData("pbook.txt", ios:in); if (!outData | !inD

35、ata) cout <<endl <<"對(duì)不起!找不到文件!" <<endl; system("pause"); return; string s; cout <<endl <<"你要?jiǎng)h除輸入姓名、電話或QQ :" cin >>s; string str; bool flag = true; while (inData >>name >>number) getline(inData, str); if (s=name) | (s=numbe

36、r) cout <<endl <<"你想刪除的聯(lián)系人:" <<endl <<endl;cout<< setiosflags(ios:left) << setw(17) << "姓名" <<" " << setw(16) << "電話號(hào)碼" <<" " << setw(18) << "QQ" <<" &

37、quot; << setw(14) << "郵編" <<" " << setw(20) << "地址 "<<endl; cout <<setiosflags(ios:left) <<setw(17) <<name <<" " <<number<<str <<endl<<endl; flag = false; break; outData <&l

38、t;setiosflags(ios:left) <<setw(17) <<name/將不刪除的信息放到temp.txt <<" " <<number <<" "<<qq<<str <<endl; if (flag) cout <<endl <<"對(duì)不起!聯(lián)系人中沒(méi)你找的人!" <<endl <<endl; else/將temp.txt的數(shù)據(jù)復(fù)制到pbook.txt,直接覆蓋要?jiǎng)h除的信息,達(dá)到刪

39、除效果 while (getline(inData, str) outData <<str <<endl; outData.close(); inData.close(); ofstream out("pbook.txt", ios:out); ifstream in("temp.txt", ios:in); if (!out | !in) cout <<endl <<"對(duì)不起!不能打開(kāi)文件!" <<endl <<endl; system("pause&

40、quot;); return; while (getline(in, str) out <<str <<endl; out.close();/ in.close(); cout <<endl <<"該聯(lián)系人信息已從通迅錄中刪除!" <<endl <<endl; system("pause"); /修改信息void book:fix() ofstream outData("temp.txt", ios:out); ifstream inData("pboo

41、k.txt", ios:in); /if (!outData | !inData) cout <<endl <<"對(duì)不起!找不到文件!" <<endl; system("pause"); return; string s; cout <<endl <<"你要修改輸入姓名或電話號(hào) :" cin >>s; bool flag = true; string str; while (inData >>name >>number) getl

42、ine(inData, str); if (s=name) | (s=number) cout <<endl <<"你想修改的聯(lián)系人:" <<endl <<endl;cout<< setiosflags(ios:left) << setw(17) << "姓名" <<" " << setw(16) << "電話號(hào)碼" <<" " << setw(18)

43、<< "QQ" <<" " << setw(14) << "郵編" <<" " << setw(20) << "地址 "<<endl; cout <<setiosflags(ios:left) <<setw(17) <<name <<" " <<number <<str <<endl; cout &

44、lt;<endl <<"請(qǐng)根據(jù)下面提示修改信息 : " <<endl; cout <<"姓名 :" ; cin >>name; cout <<"電話號(hào):" cin >>number; cout <<"QQ :" cin >>qq; cout <<"郵編 :" cin >>post; cout <<"地址 :" cin >>add

45、ress; save_new(); flag = false; break; outData <<setiosflags(ios:left) <<setw(17) <<name <<" " <<number <<str <<endl; if (flag) cout <<endl <<"對(duì)不起!聯(lián)系人中沒(méi)你找的人!" <<endl <<endl; else while (getline(inData, str) outData

46、 <<str <<endl; outData.close(); inData.close(); ofstream out("pbook.txt", 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)

47、 out <<str <<endl; out.close();/ in.close(); cout <<endl <<"該聯(lián)系人已在通迅錄中修改!" <<endl <<endl; system("pause"); /查詢聯(lián)系人void book:find() ifstream inData("pbook.txt",ios:in); if (!inData) cout <<endl <<"對(duì)不起!文件找不到!" <<endl; system("pause"); return; string s; cout <<endl <<"輸入你想查找的聯(lián)系人的姓名、電話或QQ: " cin >>s; bool flag = true; string str; while (inData >>name

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 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ì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論