




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、程序設(shè)計工程訓(xùn)練報告學(xué)生宿舍管理系統(tǒng) 課程名稱 程序設(shè)計工程訓(xùn)練姓 名 院(系) 信息科學(xué)與技術(shù)學(xué)院專業(yè)班級 學(xué) 號 指導(dǎo)教師 教務(wù)處制目 錄1 需求分析12 系統(tǒng)總框圖和功能模塊說明22.1 系統(tǒng)總框圖。22.2 功能模塊說明32.3 程序總體框架43 系統(tǒng)設(shè)計103.1 主要結(jié)構(gòu)體103.2主要功能函數(shù)104 調(diào)試情況114.1輸入密碼進(jìn)入程序114.2主界面114.2.1輸入學(xué)生信息114.2.2輸出學(xué)生信息124.2.3更新學(xué)生信息124.2.4查詢學(xué)生信息134.2.5排序134.2.6統(tǒng)計學(xué)生信息145 設(shè)計總結(jié)146 源程序清單151 需求分析 輸入正確密碼后進(jìn)入系統(tǒng),用read
2、_message()函數(shù)先讀取文件內(nèi)容,再在do while循環(huán)中用switch語句進(jìn)行選擇(選一進(jìn)入輸入模塊;選二進(jìn)入輸出模塊;選三進(jìn)入更新模塊,在更新模塊中又包含了三個小的模塊:刪除,修改,插入;選四進(jìn)入查詢模塊,在查詢模塊中可以根據(jù)信息中的學(xué)號,姓名,宿舍,樓層,樓號來進(jìn)行查詢;選五進(jìn)入排序模塊,在排序模塊中可以根據(jù)學(xué)號,宿舍,樓層,樓號進(jìn)行排序;選六進(jìn)入統(tǒng)計模塊,可以根據(jù)宿舍,樓層,樓號進(jìn)行統(tǒng)計。)退出程序時,對信息進(jìn)行保存,以便下次調(diào)用。2 系統(tǒng)總框圖和功能模塊說明2.1 系統(tǒng)總框圖1輸入函數(shù)(input_message())2輸出函數(shù)(output_message())3.讀函數(shù)(
3、read_message())a).刪除函數(shù)(del_message())4.更新模塊 b).修改函數(shù)(revise_message()) c)插入函數(shù)(insert_message())a).按姓名查詢(inquire_name())主函數(shù)5.查詢模塊 b).按學(xué)號查詢(inquire_num())c).按宿舍查詢(inquire_dormitary()d).按樓層查詢(inquire_floor()e).按宿舍樓查詢(inquire_building() 6.排序模塊 a).按學(xué)號排序(sort_num() b).按宿舍排序(sort_dormitary() c).按樓層排序(sort_f
4、loor() d).按宿舍樓排序(sort_building()7.統(tǒng)計模塊 a).按學(xué)號統(tǒng)計(count_num()b).按樓層統(tǒng)計(count_floor()c).按樓號統(tǒng)計(count_building()8保存信息(save_message()9退 出 2.2 功能模塊說明1輸入函數(shù):用來錄入數(shù)據(jù)和有關(guān)信息。2輸出函數(shù):用來輸出錄入的相關(guān)信息。3. 讀函數(shù):將文件中的數(shù)據(jù)讀入。4更新模塊:對以存信息進(jìn)行更新.有以下幾個選項:(1)刪除函數(shù):用來刪除已離校的學(xué)生信息。(2)修改函數(shù):用來修改改變宿舍的學(xué)生信息。(3)插入函數(shù):用來插入新同學(xué)的宿舍信息。5查詢模塊:輸入一項信息,可以得到存
5、入的整條信息,具體有以下: (1)按姓名查詢:輸入學(xué)生姓名,可得到整條學(xué)生信息。 (2)按學(xué)號查詢:輸入學(xué)生學(xué)號,可得到整條學(xué)生信息。 (3)按宿舍查詢:輸入宿舍號,可得到所有住在該宿舍號中的學(xué)生的所有信息。 (4)按樓層查詢:輸入樓層數(shù)后,可得到所有住在該層的學(xué)生信息。 (5)按宿舍樓查詢:輸入宿舍樓數(shù),可得到所有住在該樓的學(xué)生信息。6排序模塊:用來對錄入的信息進(jìn)行整理,使其排列有規(guī)律性。(1) 按學(xué)號排序:把輸入的學(xué)號從小到大進(jìn)行排序。(2) 按宿舍排序:把輸入的宿舍從小到大進(jìn)行排序。(3) 按樓層排序:把輸入的樓層從小到大進(jìn)行排序。(4) 按宿舍樓排序:把輸入的宿舍樓從小到大進(jìn)行排序。7
6、統(tǒng)計模塊:用來把錄入的信息進(jìn)行統(tǒng)計,使使用者清楚明了。(1) 按宿舍統(tǒng)計:輸入要統(tǒng)計的宿舍號,把這個宿舍里的所有成員輸出,并顯示在這個宿舍里的總?cè)藬?shù)。(2) 按樓層統(tǒng)計:輸入要統(tǒng)計的樓層,把所有住在這個樓層上的學(xué)生信息輸出,并顯示總?cè)藬?shù)。(3) 按樓號統(tǒng)計:輸入要統(tǒng)計的樓號,把所有住在該樓的學(xué)生信息輸出,并顯示總?cè)藬?shù)。8保存信息:對信息進(jìn)行保存,使下次打開時還存在。9退出系統(tǒng)。2.3 程序總體框架主函數(shù)流程圖:開始 n輸入密碼y讀函數(shù)輸入choice進(jìn)入輸入模塊choice 1 y進(jìn)入輸出模塊choice 2n yn 進(jìn)入更新模塊choice 3 yn進(jìn)入查詢模塊choice 4 yn 進(jìn)入排
7、序模塊choice 5讀函數(shù) y進(jìn)入統(tǒng)計模塊choice 6n yn退出choice 0 y保存函數(shù)結(jié)束修改模塊流程圖:開始輸入學(xué)號輸入choicechoice=1?輸入修改后num 是 否輸入修改后namechoice=2? 是 否輸入修改后sexchoice=3? 是 否輸入修改后agechoice=4? 是 否輸入修改后majorchoice=5? 是choice=6?輸入修改后grade 否 是 否是choice=7?輸入修改后class 否 是choice=8?輸入修改后building 否輸入修改后floor是choice=9?否choice=10?輸入修改后dormiatry是輸
8、出修改后信息結(jié)束查詢模塊流程圖: 開始輸入choiceinquire_namechoice=1? 是 否inquire_numchoice=2? 是否 是inquire_dormitarychoice=3? 否 inquire_floorchoice=4? 是 否choice=5?inquire_building 是 否choice=0? 是結(jié)束更新模塊流程圖: 開始輸入choiceoutput_message(h)del_message(h)choice=1? 是 否output_message(h)revise_message()choice=2? 是否 是output_message(h
9、)insert_message(h);choice=3? choice=0? 是 結(jié)束刪除模塊流程圖:開始輸入nump0=hp=p0-nextp-num=nump0-next=p-next;free(p); 是 否p0=p;p=p-next; p=p-next;結(jié)束 否按姓名查詢流程圖: 開始輸入name p0=h strcmp(p0-name,name)?=0 是輸出p0 否 p0=p0-next 結(jié)束 (按學(xué)號、宿舍號、樓層、宿舍樓的流程圖類似于按姓名查詢的流程圖)排序模塊流程圖: 開始輸入choiceoutput (h)sort_num()choice=1? 是 否output (h)s
10、ort_dormitary()choice=2? 是否 是choice=3?sort_floor()output (h) 否 choice=4?sort_building()output (h) 是 否choice=0? 是結(jié)束統(tǒng)計模塊流程圖: 開始輸入choicecount_dormitary()choice=1? 是 否count_floor()choice=2? 是否 是count_building()choice=3? choice=0? 是 結(jié)束3 系統(tǒng)設(shè)計3.1 主要結(jié)構(gòu)體struct stud int num; char name10; char sex8; int age; c
11、har major18; int grade; int classes; int building; int floor; int dormitary;struct stud *next; ;3.2主要功能函數(shù)input_message()/*輸入模塊*/read_message()/*讀取信息*/output_message(struct stud *p)/*輸出模塊*/del_message(struct stud *h)/*刪除學(xué)生信息*/revise_message()/*修改學(xué)生信息*/insert_message(struct stud *h)/*插入學(xué)生信息*/renew_mes
12、sage()/*更新模塊*/inquire_name()/*按姓名查詢*/inquire_num()/*按學(xué)號查詢*/inquire_dormitary()/*按宿舍號查詢*/inquire_floor()/*按樓層查詢*/inquire_building()/*按宿舍樓查詢*/inquire_message()/*查詢模塊*/sort_num()/*按學(xué)號排序*/sort_dormitary()/*按宿舍排序*/sort_floor()/*按樓層排序*/sort_building()/*按宿舍樓排序*/output(struct stud *p)/*用于輸出排序的模塊*/sort_messa
13、ge()/*排序模塊*/count_floor()/*按樓層統(tǒng)計*/count_building()/*按宿舍樓統(tǒng)計*/count_message()/*統(tǒng)計模塊*/save_message(struct stud *h)/*保存信息*/4 調(diào)試情況 4.1輸入密碼進(jìn)入程序 4.2主界面4.2.1輸入學(xué)生信息 輸入一共有多少個學(xué)生信息 完成一個學(xué)生信息登記4.2.2輸出學(xué)生信息4.2.3更新學(xué)生信息可如圖:(修改王安的性別)4.2.4查詢學(xué)生信息可如圖:(按宿舍樓查詢)4.2.5排序4.2.6統(tǒng)計學(xué)生信息如圖:(按樓層統(tǒng)計) 該程序中可能還存在一些小問題,比如有的時
14、候它會主動清屏,有的時候不會。并且我在編譯的過程中發(fā)現(xiàn)自己存在好多毛病,有粗心了等,不注意細(xì)節(jié),其實自己也知道細(xì)節(jié)決定成敗,以后我會注意。5 設(shè)計總結(jié) 通過兩周的編程,我完成了學(xué)生宿舍管理這個小系統(tǒng)。進(jìn)一步理解并掌握了c 語言中的精華指針和鍵表。程序可以流暢運行,實現(xiàn)對數(shù)據(jù)的錄入、修改、插入、刪除、排序、查詢、統(tǒng)計等基本功能。程序開始時從文件中讀取數(shù)據(jù),結(jié)束時對新數(shù)據(jù)或更新的數(shù)據(jù)進(jìn)行保存,以便下次再次調(diào)用。 在編程中也不是一帆風(fēng)順的,開始時由于對c語言的許多知識點都遺忘了,導(dǎo)致編程過程中相當(dāng)吃力,經(jīng)過一兩天的適應(yīng)后,模塊基本上編的得心應(yīng)手。但當(dāng)我編寫讀數(shù)據(jù)這個模塊時遇到了一點問題,程序總是讀出
15、一些亂碼,并不是我先前存入的數(shù)據(jù)。經(jīng)過指導(dǎo)老師耐心的指點下,終于解決了這個問題。這次高級語言程序設(shè)計,不僅鞏固了我所學(xué)到的c語言知識,還讓我認(rèn)識到了編寫一個完整的程序不僅要有必備的基礎(chǔ)知識,還要耐心,細(xì)心,遇到問題不能輕言放棄,靈感可能就會出現(xiàn)在下一秒。 課程設(shè)計是把我們所學(xué)的理論知識進(jìn)行系統(tǒng)的總結(jié)并應(yīng)用于實踐的良好機會,有利于加強我們用知識理論來分析實際問題的能力,進(jìn)而加強了我們對知識認(rèn)識的實踐度,鞏固了我們的理論知識,深化了對知識的認(rèn)識,并為走向社會打下一個良好的基礎(chǔ)。在這次課程設(shè)計中我遇到許多問題和麻煩,得到了老師的幫助和指導(dǎo),才能夠使得這次課程設(shè)計順利的進(jìn)行下去,另外,在程序調(diào)試過程中
16、,也得到很多同學(xué)的幫助,給我及時指出錯誤,提出許多寶貴意見。在此對老師和同學(xué)們表示感謝!6 源程序清單#include#include#include#define n sizeof(struct stud)/*先用結(jié)構(gòu)體定義學(xué)生信息*/struct stud int num; char name10; char sex8; int age; char major18; int grade; int classes; int building; int floor; int dormitary; struct stud *next; /*next是指向本結(jié)構(gòu)體的類型的指針類型*/;struct
17、 stud *h,*p; /*定義指向結(jié)構(gòu)體的指針變量*/file *fp; /*定義文件指針*/*建立和輸出鏈表*/struct stud *creat(void) struct stud *p1,*p2,*head; int i,k; printf(please input the total number of students:n); scanf(%d,&k); head=null; printf(please input the message of the student:nn); if(k0) head=p2=p1=(struct stud*)malloc(n); /*為head
18、,p2,p1申請存儲空間,并都指向首結(jié)點*/ for(i=1;inum); printf(input the name:n); scanf(%s,p1-name); printf(input the sex(man or female):n); scanf(%s,p1-sex); printf(input the age:n); scanf(%d,&p1-age); printf(input the major:n); scanf(%s,p1-major); printf(please input the grade and class:n); scanf(%d%d,&p1-grade,&p1
19、-classes); printf(please input the building floor and dormitary:n); scanf(%d%d%d,&p1-building,&p1-floor,&p1-dormitary); p2-next=p1; /*將新結(jié)點連到表尾*/ p2=p1; /*p2指向新的表尾*/ p2-next=null; head=head-next; save_message(head); /*將輸入的數(shù)據(jù)存入文件*/ return head;/*輸入模塊*/input_message() char v; system(cls); h=creat(); ff
20、lush(stdin); printf(nnnn press any key to the main meue!n); v=getchar(); return;/*讀取信息*/read_message() struct stud *p1,*p2; h=p1=(struct stud*)malloc(n); /*為了p1申請存儲空間,并指向首結(jié)點*/ if(fp=fopen(gx1.txt,rb)=null) printf(nnn there is no data for the monent!n); return; if(fread(p1,n,1,fp)!=1) return; /*先向p1讀
21、入一個數(shù)據(jù),若不能讀,返回*/ while(1) p2=(struct stud*)malloc(n); /*為了p2申請存儲空間*/ if(fread(p2,n,1,fp)!=1) break; p1-next=p2; p1=p2; fclose(fp); return;/*輸出模塊*/output_message(struct stud *p) char v;p=h; system(cls); if(p=null) printf(nnnnn there is no datas right now!n); printf(number name sex age major grade clas
22、s building floor dormitarynn); while(p!=null) printf(%6d%7s%7s%6d%8s%8d%8d%10d%7d%11dn,p-num,p-name,p-sex,p-age,p-major,p-grade,p-classes,p-building,p-floor,p-dormitary); p=p-next; fflush(stdin); printf(nnnn press any key to the main meue!n); v=getchar(); return;/*刪除學(xué)生信息*/del_message(struct stud *h)
23、 int num; struct stud *p,*p0; system(cls); if(h=null) return 0; printf(nn please input the number who you what to delete?n); scanf(%d,&num); p0=h; if(p0-num=num) h=p0-next; free(p0); /*若首結(jié)點是所要刪除的數(shù)據(jù),則釋放首結(jié)點*/ return 1; p=p0-next; while(p!=null) if(p-num=num) p0-next=p-next; free(p); return 1; p0=p; p=
24、p-next; return 0;/*修改學(xué)生信息*/revise_message() int num1,choice; struct stud *p0; system(cls); printf(nn please input the number who you what to revise:n); scanf(%d,&num1); system(cls); p0=h; /*將頭結(jié)點賦給p0*/ do if(p0-num=num1) printf(n which you what to revise?n); printf(n 1.numbern); printf(n 2.namen); pr
25、intf(n 3.sexn); printf(n 4.agen); printf(n 5.majorn); printf(n 6.graden); printf(n 7.classn); printf(n 8.buildingn); printf(n 9.floorn); printf(n 10.dormiatryn); scanf(%d,&choice); switch(choice) case 1:printf(n input the new number:n); scanf(%d,&p0-num);break; case 2:printf(n input the new name:n);
26、 scanf(%s,p0-name);break; case 3:printf(n input the new sex:n); scanf(%s,p0-sex);break; case 4:printf(n input the new age:n); scanf(%d,&p0-age);break; case 5:printf(n input the new major:n); scanf(%s,p0-major);break; case 6:printf(n input the new grade:n); scanf(%d,&p0-grade);break; case 7:printf(n
27、input the new class:n); scanf(%d,&p0-classes);break; case 8:printf(n input the new building:n); scanf(%d,&p0-building);break; case 9:printf(n input the new floor:n); scanf(%d,&p0-floor);break; case 10:printf(n input the new dormitary:n); scanf(%d,&p0-dormitary);break; break; else p0=p0-next; while(p
28、0!=null);/*插入學(xué)生信息*/insert_message(struct stud *h) struct stud *p,*p0; p=(struct stud *)malloc(n); system(cls); printf(please input the number of the student:n); scanf(%d,&p-num); printf(input the name:n); scanf(%s,p-name); printf(input the sex(man or female):n); scanf(%s,p-sex); printf(input the age
29、:n); scanf(%d,&p-age); printf(input the major:n); scanf(%s,p-major); printf(please input the grade and class:n); scanf(%d%d,&p-grade,&p-classes); printf(please input the building floor and dormitary:n); scanf(%d%d%d,&p-building,&p-floor,&p-dormitary); p-next=null; if(h=null) h=p; return 1; p0=h; if(
30、p0-num)(p-num) /*按學(xué)號順序插入*/ p-next=h; h=p; return 1; while(p0-next)!=null&(p0-next-num)num) p0=p0-next; if(p0-next=null) p0-next=p; return 1; else if(p0-next-num)=(p-num) free(p); return 0; p-next=p0-next; p0-next=p; return 1;/*更新模塊*/renew_message() int choice; do system(cls); printf(nnn renew messag
31、enn); printf( 1.delete messagenn); printf( 2.revise messagenn); printf( 3.insert messagenn); printf( 0.return the main menunn); printf( please choice(0-3):); scanf(%d,&choice); switch(choice) case 1:del_message(h);output_message(h);break; case 2:revise_message();output_message(h);break; case 3:inser
32、t_message(h);output_message(h);break; case 0:break; while(choice!=0);/*按姓名查詢*/inquire_name() char v,name10; struct stud *p0; system(cls); printf(nnn please input the name who you what to find:nn); scanf(n%s,name); p0=h; while(p0!=null) if(strcmp(p0-name,name)=0) /*用比較函數(shù)比較*/ printf(nn*inquire by name
33、*nn); printf(number name sex age major grade class building floor dormitarynn); printf(%6d%7s%7s%6d%8s%8d%8d%10d%7d%11dn,p0-num,p0-name,p0-sex,p0-age,p0-major,p0-grade,p0-classes,p0-building,p0-floor,p0-dormitary); p0=p0-next; fflush(stdin); printf(nnnn press any key to the main meue!n); v=getchar()
34、; return;/*按學(xué)號查詢*/inquire_num() char v;int num2; struct stud *p0; system(cls); printf(nnn please input the number who you what to find:nn); scanf(n%d,&num2); p0=h; while(p0!=null) if(p0-num=num2) printf(nn*inquire by number*nn); printf(number name sex age major grade class building floor dormitarynn
35、); printf(%6d%7s%7s%6d%8s%8d%8d%10d%7d%11dn,p0-num,p0-name,p0-sex,p0-age,p0-major,p0-grade,p0-classes,p0-building,p0-floor,p0-dormitary); p0=p0-next; fflush(stdin); printf(nnnn press any key to the main meue!n);v=getchar(); return;/*按宿舍號查詢*/inquire_dormitary() char v;int dormitary2; struct stud *p0;
36、 system(cls); printf(nnn please input the dormitary what you want to find:nn); scanf(n%d,&dormitary2); p0=h; while(p0!=null) if(p0-dormitary=dormitary2) printf(nn*inquire by dormitary*nn); printf(number name sex age major grade class building floor dormitarynn); printf(%6d%7s%7s%6d%8s%8d%8d%10d%7d%1
37、1dn,p0-num,p0-name,p0-sex,p0-age,p0-major,p0-grade,p0-classes,p0-building,p0-floor,p0-dormitary); p0=p0-next; fflush(stdin); printf(nnnn press any key to the main meue!n); v=getchar(); return;/*按樓層查詢*/inquire_floor() char v;int floor2; struct stud *p0; system(cls); printf(nnn please input the floor
38、what you want to find:nn); scanf(%d,&floor2); p0=h; while(p0!=null) if(p0-floor=floor2) printf(nn*inquire by floor*nn); printf(number name sex age major grade class building floor dormitarynn); printf(%6d%7s%7s%6d%8s%8d%8d%10d%7d%11dn,p0-num,p0-name,p0-sex,p0-age,p0-major,p0-grade,p0-classes,p0-building,p0-floor,p0-dormitary); p0=p0-next; fflush(stdin);
溫馨提示
- 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 房屋委托建筑合同范本
- 獸藥批發(fā)與配送考核試卷
- 科技成果展覽中的視覺傳達(dá)設(shè)計
- 數(shù)字內(nèi)容創(chuàng)作者的版權(quán)知識與維權(quán)能力考核試卷
- 保健食品產(chǎn)業(yè)可持續(xù)發(fā)展戰(zhàn)略與實踐考核試卷
- 電子政務(wù)技術(shù)在公共健康管理中的應(yīng)用前景
- 律師區(qū)塊鏈技術(shù)應(yīng)用法律咨詢考核試卷
- 用工合同范本簡易
- 人事部與企業(yè)目標(biāo)的對齊計劃
- 太陽能器具在戶外音樂教育活動的供電考核試卷
- 青島版二年級數(shù)學(xué)下冊課程綱要
- 光伏電氣設(shè)備試驗方案
- 經(jīng)濟法律法規(guī)基礎(chǔ)知識單選題100道及答案
- 新蘇教版三年級科學(xué)下冊全冊課件【全套】
- 2024-2030年中國精細(xì)化工行業(yè)發(fā)展分析及發(fā)展前景與投資研究報告
- 2024至2030年中國非標(biāo)自動化行業(yè)需求領(lǐng)域與供需平衡預(yù)測分析報告
- 2024年重慶市高考生物試卷(含答案解析)
- 2024年(學(xué)習(xí)強國)思想政治理論知識考試題庫與答案
- DL∕T 540-2013 氣體繼電器檢驗規(guī)程
- 《食品安全風(fēng)險管控清單》
- 數(shù)控機床技術(shù)先進(jìn)性
評論
0/150
提交評論