面向?qū)ο笳n程設(shè)計(jì)報(bào)告宿舍管理系統(tǒng)_第1頁(yè)
面向?qū)ο笳n程設(shè)計(jì)報(bào)告宿舍管理系統(tǒng)_第2頁(yè)
面向?qū)ο笳n程設(shè)計(jì)報(bào)告宿舍管理系統(tǒng)_第3頁(yè)
面向?qū)ο笳n程設(shè)計(jì)報(bào)告宿舍管理系統(tǒng)_第4頁(yè)
面向?qū)ο笳n程設(shè)計(jì)報(bào)告宿舍管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩11頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、.面向?qū)ο笳n程設(shè)計(jì)報(bào)告課程設(shè)計(jì)題目: 宿舍管理系統(tǒng) 學(xué) 生 姓 名: 肖 瑩 專(zhuān) 業(yè): 計(jì)算機(jī)應(yīng)用技術(shù)班 級(jí): 1240301學(xué) 號(hào): 201240030145指 導(dǎo) 教 師: 陽(yáng)紅星 2014年 1月1日 面向?qū)ο笳n程設(shè)計(jì)報(bào)告1.程序設(shè)計(jì)內(nèi)容及要求 1) 任務(wù):為宿舍管理人員編寫(xiě)一個(gè)宿舍管理查詢(xún)軟件, 程序設(shè)計(jì)要求:A. 采用交互工作方式B. 建立數(shù)據(jù)文件 ,數(shù)據(jù)文件按關(guān)鍵字(姓名、學(xué)號(hào)、房號(hào))進(jìn)行排序(冒泡、選擇、插入排序等任選一種)2) 查詢(xún)菜單: (用二分查找實(shí)現(xiàn)以下操作)A. 按姓名查詢(xún) B. 按學(xué)號(hào)查詢(xún) C. 按

2、房號(hào)查詢(xún)3) 打印任一查詢(xún)結(jié)果(可以連續(xù)操作)2、課程設(shè)計(jì)的目的了解面向?qū)ο蟮暮诵母拍钜约皩?duì)象的具體含義,熟悉用面向?qū)ο笕ゾ幊?,掌握面向?qū)ο蟮木幊汰h(huán)境并充分利用。3、方法設(shè)計(jì)與論證構(gòu)思流程圖:4、算法說(shuō)明 主要有主菜單函數(shù),插入功能子菜單函數(shù),查找功能子菜單函數(shù),學(xué)生信息錄入函數(shù),顯示函數(shù),排序函數(shù),插入函數(shù)以及查找函數(shù)。在每個(gè)區(qū)域中會(huì)調(diào)用不同的函數(shù)來(lái)實(shí)現(xiàn)主要的功能。比如,在學(xué)生顯示這個(gè)功能里調(diào)用顯示函數(shù);在插入功能里調(diào)用子菜單函數(shù);在顯示信息時(shí)調(diào)用排序函數(shù)先對(duì)需要輸出的信心進(jìn)行排序,然后再輸出;在查找功能里會(huì)調(diào)用查找函數(shù)來(lái)進(jìn)行查找,包括按照班級(jí),學(xué)號(hào),姓名,宿舍號(hào)等查詢(xún)。

3、5、設(shè)計(jì)代碼#include <iostream>#include <string>#include <fstream>#include <ctime>using namespace std;class studentprivate: long int stu_num; /學(xué)號(hào),宿舍號(hào) char stu_name10; /姓名 char class_name10; /班別char house_name10; /宿舍public: student() stu_num=0; stu_name0 =0; class_name0 =0; house_na

4、me0 =0;student:student(long a, char * b,char *c,char *d) Setdata(a , b, c, d); char * Getstuname(void) /姓名查找 return stu_name ;long Getstunum(void) /學(xué)號(hào)查找 return stu_num;char * Gethousename(void) /宿舍號(hào)查找 return house_name;char * Getclassname(void) /按班級(jí)查找 return class_name;void Setdata(long a, char *b,c

5、har *c,char *d) stu_num = a; strcpy(stu_name, b); strcpy(class_name, c); strcpy(house_name, d);void Show(void) cout<<"學(xué)號(hào):"<<stu_num<<"t"<<"姓名:"<<stu_name<<"t" cout<<"班級(jí)號(hào):"<<class_name<<"tt&qu

6、ot;<<"宿舍號(hào):"<<house_name<<"n"void main(void)student s1;int flags=0; long stu_num; /學(xué)號(hào) char stu_name40; /姓名 char class_name40; /班級(jí) char house_name20; /宿舍t(yī)ime_t t; time(&t); ifstream file1; ofstream file3; char flag = 'y' cout<< "-學(xué)生成績(jī)管理系統(tǒng)-&q

7、uot;<<endl; while( flag='y' | flag='Y') cout<<"-n" cout<<"tt 1: 已 經(jīng) 注 冊(cè) 學(xué) 生! nn" cout<<"tt 2: 通 過(guò) 學(xué) 號(hào) 查 看 學(xué) 生 信 息! nn" cout<<"tt 3: 通 過(guò) 宿 舍 號(hào) 查 看 學(xué) 生 信 息! nn" cout<<"tt 4: 通 過(guò) 姓 名 查 看 學(xué) 生 信 息! nn" c

8、out<<"tt 5: 通 過(guò) 班 級(jí) 查 看 學(xué) 生 信 息! nn" cout<<"tt 6: 顯 示 全 部 學(xué) 生 信 息! nn" cout<<"tt 7: 通 過(guò) 學(xué) 號(hào) 修 改 學(xué) 生 信 息! nn" cout<<"tt 8: 通 過(guò) 學(xué) 號(hào) 刪 除 學(xué) 生 信 息! n" cout<<"-n" cout<<"請(qǐng)輸入選擇:" char choice; cin>>choice;

9、switch(choice) case '1': file3.open("c:stu.dat",ios:app|ios:binary);input: flags=0; cout<<"輸入學(xué)號(hào):" cin>>stu_num; while(!file1.eof() int n; file1.read(char *)&s1,sizeof(student); n=file1.gcount(); if(n=sizeof(student) if(s1.Getstunum()=stu_num) flags=1; file

10、1.clear(); file1.close(); if (flags=1) cin.clear(); cout << "學(xué)號(hào)重復(fù),請(qǐng)重輸入!" << endl; goto input; cout<<"輸入姓名:" cin>>stu_name; cout<<"輸入班級(jí):" cin>>class_name; cout<<"輸入宿舍:" cin>>house_name; s1.Setdata(stu_num,stu_name

11、,class_name,house_name); file3.write(char*)&s1,sizeof(s1); file3.clear(); file3.close(); break; case '2': /按學(xué)號(hào)查找 cout<<"請(qǐng)輸入要查找學(xué)生的學(xué)號(hào):" cin>>stu_num; while(!file1.eof() int n; file1.read(char *)&s1,sizeof(student); n=file1.gcount(); if(n=sizeof(student) if(s1.Gets

12、tunum()=stu_num) /顯示學(xué)生信息 s1.Show(); flags=1; file1.clear(); file1.close(); if (flags=0) cout << "對(duì)不起,沒(méi)有找學(xué)號(hào)為:"<< stu_num <<"的學(xué)生記錄!" << endl; flags=0; break; case '3': /按宿舍號(hào)查找 cout<<"請(qǐng)輸入要查找的宿舍號(hào):" cin>>house_name; file1.open(&quo

13、t;c:stu.dat",ios:in | ios:binary | ios:beg);/按讀方式打開(kāi)文件 while(!file1.eof() int n; file1.read(char *)&s1,sizeof(student); n=file1.gcount(); if(n=sizeof(student) if(strcmp(s1.Gethousename(),house_name)=0) s1.Show(); flags=1; file1.clear(); file1.close(); if (flags=0) cout << "對(duì)不起,沒(méi)有找

14、到宿舍為:"<< house_name <<"的學(xué)生記錄!" << endl; flags=0; break; case '4': /按姓名查找 cout<<"請(qǐng)輸入要查找學(xué)生的姓名:" cin>>stu_name; file1.open("c:stu.dat",ios:in | ios:binary | ios:beg);/按讀方式打開(kāi)文件 while(!file1.eof() int n; file1.read(char *)&s1,si

15、zeof(student); n=file1.gcount(); if(n=sizeof(student) if(strcmp(s1. Getstuname(),stu_name)=0) s1.Show(); flags=1; file1.clear(); file1.close(); if (flags=0) cout << "對(duì)不起,沒(méi)有找到姓名為:"<< stu_name <<"的學(xué)生記錄!" << endl; flags=0; break; case '5': /按班級(jí)查找 cout

16、<<"請(qǐng)輸入要查找的班級(jí)名稱(chēng):" cin>>class_name; file1.open("c:stu.dat",ios:in | ios:binary | ios:beg);/按讀方式打開(kāi)文件 while(!file1.eof() int n; file1.read(char *)&s1,sizeof(student); n=file1.gcount(); if(n=sizeof(student) if(strcmp(s1. Getclassname(),class_name)=0) s1.Show(); flags=1

17、; file1.clear(); file1.close(); if (flags=0) cout << "對(duì)不起,沒(méi)有找到班級(jí)為:"<< class_name <<"的學(xué)生記錄!" << endl; flags=0; break; case '6': /顯示全部學(xué)生信息 file1.open("c:stu.dat",ios:in | ios:binary);/按讀方式打開(kāi)文件 while(!file1.eof() int n; file1.read(char *)&s1,sizeof(student); n=file1.gcount(); if(n=sizeof(student) s1.Show(); flag

溫馨提示

  • 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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論