C語言課程設(shè)計(jì)學(xué)生宿舍管理系統(tǒng)_第1頁
C語言課程設(shè)計(jì)學(xué)生宿舍管理系統(tǒng)_第2頁
C語言課程設(shè)計(jì)學(xué)生宿舍管理系統(tǒng)_第3頁
C語言課程設(shè)計(jì)學(xué)生宿舍管理系統(tǒng)_第4頁
C語言課程設(shè)計(jì)學(xué)生宿舍管理系統(tǒng)_第5頁
已閱讀5頁,還剩52頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

年4月19日C語言課程設(shè)計(jì)學(xué)生宿舍管理系統(tǒng)文檔僅供參考程序設(shè)計(jì)工程訓(xùn)練報(bào)告學(xué)生宿舍管理系統(tǒng)課程名稱程序設(shè)計(jì)工程訓(xùn)練姓名院(系)信息科學(xué)與技術(shù)學(xué)院專業(yè)班級學(xué)號指導(dǎo)教師教務(wù)處制目錄96091需求分析 17782系統(tǒng)總框圖和功能模塊說明 210402.1系統(tǒng)總框圖。 2149322.2功能模塊說明 365822.3程序總體框架 4108673系統(tǒng)設(shè)計(jì) 1028783.1主要結(jié)構(gòu)體 1042913.2主要功能函數(shù) 1096514調(diào)試情況 11242784.1輸入密碼進(jìn)入程序 11210634.2主界面 11182624.2.1輸入學(xué)生信息 11138784.2.2輸出學(xué)生信息 1227844.2.3更新學(xué)生信息 12180964.2.4查詢學(xué)生信息 13196574.2.5排序 1364184.2.6統(tǒng)計(jì)學(xué)生信息 14140585設(shè)計(jì)總結(jié) 14148446源程序清單 151需求分析輸入正確密碼后進(jìn)入系統(tǒng),用read_message()函數(shù)先讀取文件內(nèi)容,再在dowhile循環(huán)中用switch語句進(jìn)行選擇(選一進(jìn)入輸入模塊;選二進(jìn)入輸出模塊;選三進(jìn)入更新模塊,在更新模塊中又包含了三個(gè)小的模塊:刪除,修改,插入;選四進(jìn)入查詢模塊,在查詢模塊中能夠根據(jù)信息中的學(xué)號,姓名,宿舍,樓層,樓號來進(jìn)行查詢;選五進(jìn)入排序模塊,在排序模塊中能夠根據(jù)學(xué)號,宿舍,樓層,樓號進(jìn)行排序;選六進(jìn)入統(tǒng)計(jì)模塊,能夠根據(jù)宿舍,樓層,樓號進(jìn)行統(tǒng)計(jì)。)退出程序時(shí),對信息進(jìn)行保存,以便下次調(diào)用。

2系統(tǒng)總框圖和功能模塊說明2.1系統(tǒng)總框圖1.輸入函數(shù)(input_message()1.輸入函數(shù)(input_message())2.輸出函數(shù)(2.輸出函數(shù)(output_message())3.讀函數(shù)(read_message()3.讀函數(shù)(read_message())a).刪除函數(shù)(del_message())4.更新模塊b).修改函數(shù)(revise_message())4.更新模塊c)插入函數(shù)(insert_message())a).按姓名查詢(inquire_name())主函數(shù)主函數(shù)5.查詢模塊c).按宿舍查詢(inquire_dormitary())d).按樓層查詢(inquire_floor())e).按宿舍樓查詢(inquire_building())6.排序模塊a).按學(xué)號排序(sort_num())6.排序模塊b).按宿舍排序(sort_dormitary())c).按樓層排序(sort_floor())d).按宿舍樓排序(sort_building())7.統(tǒng)計(jì)模塊a).按學(xué)號統(tǒng)計(jì)(count_num())7.統(tǒng)計(jì)模塊b).按樓層統(tǒng)計(jì)(count_floor())c).按樓號統(tǒng)計(jì)(count_building())8.保存信息(8.保存信息(save_message())9.退出9.退出2.2功能模塊說明1.輸入函數(shù):用來錄入數(shù)據(jù)和有關(guān)信息。2.輸出函數(shù):用來輸出錄入的相關(guān)信息。3.讀函數(shù):將文件中的數(shù)據(jù)讀入。4.更新模塊:對以存信息進(jìn)行更新.有以下幾個(gè)選項(xiàng):(1)刪除函數(shù):用來刪除已離校的學(xué)生信息。(2)修改函數(shù):用來修改改變宿舍的學(xué)生信息。(3)插入函數(shù):用來插入新同學(xué)的宿舍信息。5.查詢模塊:輸入一項(xiàng)信息,能夠得到存入的整條信息,具體有以下:(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.統(tǒng)計(jì)模塊:用來把錄入的信息進(jìn)行統(tǒng)計(jì),使使用者清楚明了。(1)按宿舍統(tǒng)計(jì):輸入要統(tǒng)計(jì)的宿舍號,把這個(gè)宿舍里的所有成員輸出,并顯示在這個(gè)宿舍里的總?cè)藬?shù)。(2)按樓層統(tǒng)計(jì):輸入要統(tǒng)計(jì)的樓層,把所有住在這個(gè)樓層上的學(xué)生信息輸出,并顯示總?cè)藬?shù)。(3)按樓號統(tǒng)計(jì):輸入要統(tǒng)計(jì)的樓號,把所有住在該樓的學(xué)生信息輸出,并顯示總?cè)藬?shù)。8.保存信息:對信息進(jìn)行保存,使下次打開時(shí)還存在。9.退出系統(tǒng)。2.3程序總體框架主函數(shù)流程圖:開始開始N輸入密碼輸入密碼Y讀函數(shù)讀函數(shù)輸入choice輸入choice進(jìn)入輸入模塊Choice1進(jìn)入輸入模塊Choice1進(jìn)入輸出模塊Choice2進(jìn)入輸出模塊Choice2N進(jìn)入更新模塊Choice3進(jìn)入更新模塊Choice3N進(jìn)入查詢模塊Choice4進(jìn)入查詢模塊Choice4N進(jìn)入排序模塊Choice5讀函數(shù)進(jìn)入排序模塊Choice5讀函數(shù)進(jìn)入統(tǒng)計(jì)模塊Choice6進(jìn)入統(tǒng)計(jì)模塊Choice6N退出Choice0退出Choice0保存函數(shù)保存函數(shù)結(jié)束結(jié)束修改模塊流程圖:開始開始輸入學(xué)號輸入學(xué)號輸入choice輸入choicechoice=1?輸入修改后num是choice=1?輸入修改后num否輸入修改后namechoice=2?是輸入修改后namechoice=2?否輸入修改后sexchoice=3?是輸入修改后sexchoice=3?否輸入修改后agechoice=4?是輸入修改后agechoice=4?否輸入修改后majorchoice=5?是輸入修改后majorchoice=5?CChoice=6?輸入修改后grade否是否是Choice=7?Choice=7?輸入修改后class輸入修改后class否是Choice=8?輸入修改后buildingChoice=8?輸入修改后building否輸入修改后floor是C輸入修改后floorChoice=9?否Choice=10?輸入修改后dormiatry是Choice=10?輸入修改后dormiatry輸出修改后信息輸出修改后信息結(jié)束結(jié)束查詢模塊流程圖:開始開始輸入choice輸入choiceInquire_namechoice=1?是Inquire_namechoice=1? 否Inquire_numchoice=2?是Inquire_numchoice=2?否是Inquire_dormitarychoice=3?Inquire_dormitarychoice=3?否Inquire_floorchoice=4?是Inquire_floorchoice=4?否choice=5?Inquire_building是choice=5?Inquire_building否choice=0?是choice=0?結(jié)束結(jié)束更新模塊流程圖:開始開始輸入choice輸入choiceoutput_message(h)del_message(h)choice=1?是output_message(h)del_message(h)choice=1? 否output_message(h)revise_message()choice=2?是output_message(h)revise_message()choice=2?否是output_message(h)insert_message(h);choice=3?output_message(h)insert_message(h);choice=3?choice=0?是choice=0?結(jié)束結(jié)束刪除模塊流程圖:開始開始輸入num輸入nump0=hp0=hp=p0->nextp=p0->nextp->num==nump0->next=p->next;free(p);p->num==nump0->next=p->next;free(p);否p0=p;p=p->next;p0=p;p=p->next;p=p->next;結(jié)束否按姓名查詢流程圖:開始開始輸入name輸入namep0=h p0=hstrcmp(p0->name,name)strcmp(p0->name,name)?==0是輸出p0輸出p0否p0=p0->nextp0=p0->next結(jié)束結(jié)束(按學(xué)號、宿舍號、樓層、宿舍樓的流程圖類似于按姓名查詢的流程圖)排序模塊流程圖:開始開始輸入choice輸入choiceoutput(h)sort_num()choice=1?是output(h)sort_num()choice=1? 否output(h)sort_dormitary()choice=2?是output(h)sort_dormitary()choice=2?否是choice=3?choice=3?sort_floor()output(h)否choice=4?sort_building()choice=4?sort_building()output(h)否choice=0?是choice=0?結(jié)束結(jié)束統(tǒng)計(jì)模塊流程圖:開始開始輸入choice輸入choicecount_dormitary()choice=1?是count_dormitary()choice=1? 否count_floor()choice=2?是count_floor()choice=2?否是count_building()choice=3?count_building()choice=3?choice=0?是choice=0?結(jié)束結(jié)束3系統(tǒng)設(shè)計(jì)3.1主要結(jié)構(gòu)體structstud{intnum;charname[10];charsex[8];intage;charmajor[18];intgrade;intclasses;intbuilding;intfloor;intdormitary;structstud*next;};3.2主要功能函數(shù)input_message()/*輸入模塊*/read_message()/*讀取信息*/output_message(structstud*p)/*輸出模塊*/del_message(structstud*h)/*刪除學(xué)生信息*/revise_message()/*修改學(xué)生信息*/insert_message(structstud*h)/*插入學(xué)生信息*/renew_message()/*更新模塊*/inquire_name()/*按姓名查詢*/inquire_num()/*按學(xué)號查詢*/inquire_dormitary()/*按宿舍號查詢*/inquire_floor()/*按樓層查詢*/inquire_building()/*按宿舍樓查詢*/inquire_message()/*查詢模塊*/sort_num()/*按學(xué)號排序*/sort_dormitary()/*按宿舍排序*/sort_floor()/*按樓層排序*/sort_building()/*按宿舍樓排序*/output(structstud*p)/*用于輸出排序的模塊*/sort_message()/*排序模塊*/count_floor()/*按樓層統(tǒng)計(jì)*/count_building()/*按宿舍樓統(tǒng)計(jì)*/count_message()/*統(tǒng)計(jì)模塊*/save_message(structstud*h)/*保存信息*/4調(diào)試情況4.1輸入密碼進(jìn)入程序4.2主界面4.2.1輸入學(xué)生信息輸入一共有多少個(gè)學(xué)生信息完成一個(gè)學(xué)生信息登記4.2.2輸出學(xué)生信息4.2.3更新學(xué)生信息可如圖:(修改王安的性別)4.2.4查詢學(xué)生信息可如圖:(按宿舍樓查詢)4.2.5排序4.2.6統(tǒng)計(jì)學(xué)生信息如圖:(按樓層統(tǒng)計(jì))該程序中可能還存在一些小問題,比如有的時(shí)候它會主動清屏,有的時(shí)候不會。而且我在編譯的過程中發(fā)現(xiàn)自己存在好多毛病,有粗心了等,不注意細(xì)節(jié),其實(shí)自己也知道細(xì)節(jié)決定成敗,以后我會注意。5設(shè)計(jì)總結(jié)經(jīng)過兩周的編程,我完成了學(xué)生宿舍管理這個(gè)小系統(tǒng)。進(jìn)一步理解并掌握了C語言中的精華指針和鍵表。程序能夠流暢運(yùn)行,實(shí)現(xiàn)對數(shù)據(jù)的錄入、修改、插入、刪除、排序、查詢、統(tǒng)計(jì)等基本功能。程序開始時(shí)從文件中讀取數(shù)據(jù),結(jié)束時(shí)對新數(shù)據(jù)或更新的數(shù)據(jù)進(jìn)行保存,以便下次再次調(diào)用。在編程中也不是一帆風(fēng)順的,開始時(shí)由于對C語言的許多知識點(diǎn)都遺忘了,導(dǎo)致編程過程中相當(dāng)吃力,經(jīng)過一兩天的適應(yīng)后,模塊基本上編的得心應(yīng)手。但當(dāng)我編寫讀數(shù)據(jù)這個(gè)模塊時(shí)遇到了一點(diǎn)問題,程序總是讀出一些亂碼,并不是我先前存入的數(shù)據(jù)。經(jīng)過指導(dǎo)老師耐心的指點(diǎn)下,終于解決了這個(gè)問題。這次高級語言程序設(shè)計(jì),不但鞏固了我所學(xué)到的C語言知識,還讓我認(rèn)識到了編寫一個(gè)完整的程序不但要有必備的基礎(chǔ)知識,還要耐心,細(xì)心,遇到問題不能輕言放棄,靈感可能就會出現(xiàn)在下一秒。課程設(shè)計(jì)是把我們所學(xué)的理論知識進(jìn)行系統(tǒng)的總結(jié)并應(yīng)用于實(shí)踐的良好機(jī)會,有利于加強(qiáng)我們用知識理論來分析實(shí)際問題的能力,進(jìn)而加強(qiáng)了我們對知識認(rèn)識的實(shí)踐度,鞏固了我們的理論知識,深化了對知識的認(rèn)識,并為走向社會打下一個(gè)良好的基礎(chǔ)。在這次課程設(shè)計(jì)中我遇到許多問題和麻煩,得到了老師的幫助和指導(dǎo),才能夠使得這次課程設(shè)計(jì)順利的進(jìn)行下去,另外,在程序調(diào)試過程中,也得到很多同學(xué)的幫助,給我及時(shí)指出錯(cuò)誤,提出許多寶貴意見。在此對老師和同學(xué)們表示感謝!6源程序清單#include<stdio.h>#include<string.h>#include<stdlib.h>#defineNsizeof(structstud)/*先用結(jié)構(gòu)體定義學(xué)生信息*/structstud{intnum;charname[10];charsex[8];intage;charmajor[18];intgrade;intclasses;intbuilding;intfloor;intdormitary;structstud*next;/*next是指向本結(jié)構(gòu)體的類型的指針類型*/};structstud*h,*p;/*定義指向結(jié)構(gòu)體的指針變量*/FILE*fp;/*定義文件指針*//*建立和輸出鏈表*/structstud*creat(void){structstud*p1,*p2,*head;inti,k;printf("Pleaseinputthetotalnumberofstudents:\n");scanf("%d",&k);head=NULL;printf("Pleaseinputthemessageofthestudent:\n\n");if(k>0){head=p2=p1=(structstud*)malloc(N);/*為head,p2,p1申請存儲空間,并都指向首結(jié)點(diǎn)*/for(i=1;i<=k;i++){p1=(structstud*)malloc(N);printf("Pleaseinputthenumberofthestudent:\n");scanf("%d",&p1->num);printf("Inputthename:\n");scanf("%s",p1->name);printf("Inputthesex(manorfemale):\n");scanf("%s",p1->sex);printf("Inputtheage:\n");scanf("%d",&p1->age);printf("Inputthemajor:\n");scanf("%s",p1->major);printf("Pleaseinputthegradeandclass:\n");scanf("%d%d",&p1->grade,&p1->classes);printf("Pleaseinputthebuildingflooranddormitary:\n");scanf("%d%d%d",&p1->building,&p1->floor,&p1->dormitary);p2->next=p1;/*將新結(jié)點(diǎn)連到表尾*/p2=p1;/*p2指向新的表尾*/}p2->next=NULL;head=head->next;}save_message(head);/*將輸入的數(shù)據(jù)存入文件*/returnhead;}/*輸入模塊*/input_message(){charv;system("cls");h=creat();fflush(stdin);printf("\n\n\n\n\pressanykeytothemainmeue!!!!\n");v=getchar();return;}/*讀取信息*/read_message(){structstud*p1,*p2;h=p1=(structstud*)malloc(N);/*為了p1申請存儲空間,并指向首結(jié)點(diǎn)*/if((fp=fopen("gx1.txt","rb"))==NULL){printf("\n\n\nThereisnodataforthemonent!\n");return;}if(fread(p1,N,1,fp)!=1)return;/*先向p1讀入一個(gè)數(shù)據(jù),若不能讀,返回*/while(1){p2=(structstud*)malloc(N);/*為了p2申請存儲空間*/if(fread(p2,N,1,fp)!=1)break;p1->next=p2;p1=p2;}fclose(fp);return;}/*輸出模塊*/output_message(structstud*p){charv; p=h;system("cls");if(p==NULL)printf("\n\n\n\n\nThereisnodatasrightnow!\n");printf("numbernamesexagemajorgradeclassbuildingfloordormitary\n\n");while(p!=NULL){printf("%6d%7s%7s%6d%8s%8d%8d%10d%7d%11d\n",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("\n\n\n\n\pressanykeytothemainmeue!!!!\n");v=getchar();return;}/*刪除學(xué)生信息*/del_message(structstud*h){intnum;structstud*p,*p0;system("cls");if(h==NULL)return0;printf("\n\nPleaseinputthenumberwhoyouwhattodelete?\n");scanf("%d",&num);p0=h;if(p0->num==num){h=p0->next;free(p0);/*若首結(jié)點(diǎn)是所要刪除的數(shù)據(jù),則釋放首結(jié)點(diǎn)*/return1;}p=p0->next;while(p!=NULL){if(p->num==num){p0->next=p->next;free(p);return1;}p0=p;p=p->next;}return0;}/*修改學(xué)生信息*/revise_message(){intnum1,choice;structstud*p0;system("cls");printf("\n\nPleaseinputthenumberwhoyouwhattorevise:\n");scanf("%d",&num1);system("cls");p0=h;/*將頭結(jié)點(diǎn)賦給p0*/do{if(p0->num==num1){printf("\nWhichyouwhattorevise?\n");printf("\n1.number\n");printf("\\n");printf("\n3.sex\n");printf("\n4.age\n");printf("\n5.major\n");printf("\n6.grade\n");printf("\n7.class\n");printf("\n8.building\n");printf("\n9.floor\n");printf("\n10.dormiatry\n");scanf("%d",&choice);switch(choice){case1:printf("\nInputthenewnumber:\n");scanf("%d",&p0->num);break;case2:printf("\nInputthenewname:\n");scanf("%s",p0->name);break;case3:printf("\nInputthenewsex:\n");scanf("%s",p0->sex);break;case4:printf("\nInputthenewage:\n");scanf("%d",&p0->age);break;case5:printf("\nInputthenewmajor:\n");scanf("%s",p0->major);break;case6:printf("\nInputthenewgrade:\n");scanf("%d",&p0->grade);break;case7:printf("\nInputthenewclass:\n");scanf("%d",&p0->classes);break;case8:printf("\nInputthenewbuilding:\n");scanf("%d",&p0->building);break;case9:printf("\nInputthenewfloor:\n");scanf("%d",&p0->floor);break;case10:printf("\nInputthenewdormitary:\n");scanf("%d",&p0->dormitary);break;}break;}elsep0=p0->next;}while(p0!=NULL);}/*插入學(xué)生信息*/insert_message(structstud*h){structstud*p,*p0;p=(structstud*)malloc(N);system("cls");printf("Pleaseinputthenumberofthestudent:\n");scanf("%d",&p->num);printf("Inputthename:\n");scanf("%s",p->name);printf("Inputthesex(manorfemale):\n");scanf("%s",p->sex);printf("Inputtheage:\n");scanf("%d",&p->age);printf("Inputthemajor:\n");scanf("%s",p->major);printf("Pleaseinputthegradeandclass:\n");scanf("%d%d",&p->grade,&p->classes);printf("Pleaseinputthebuildingflooranddormitary:\n");scanf("%d%d%d",&p->building,&p->floor,&p->dormitary);p->next=NULL;if(h==NULL){h=p;return1;}p0=h;if((p0->num)>(p->num))/*按學(xué)號順序插入*/{p->next=h;h=p;return1;}while((p0->next)!=NULL&&(p0->next->num)<(p->num))p0=p0->next;if(p0->next==NULL){p0->next=p;return1;}elseif((p0->next->num)==(p->num)){free(p);return0;}p->next=p0->next;p0->next=p;return1;}/*更新模塊*/renew_message(){intchoice;do{system("cls");printf("\n\n\n~~~~~~~~'Renewmessage~~~~~~~~\n\n");printf("1.Deletemessage\n\n");printf("2.Revisemessage\n\n");printf("3.Insertmessage\n\n");printf("0.Returnthemainmenu\n\n");printf("Pleasechoice(0-3):");scanf("%d",&choice);switch(choice){case1:del_message(h);output_message(h);break;case2:revise_message();output_message(h);break;case3:insert_message(h);output_message(h);break;case0:break;}}while(choice!=0);}/*按姓名查詢*/inquire_name(){charv,name[10];structstud*p0;system("cls");printf("\n\n\nPleaseinputthenamewhoyouwhattofind:\n\n");scanf("\n%s",name);p0=h;while(p0!=NULL){if(strcmp(p0->name,name)==0)/*用比較函數(shù)比較*/{printf("\n\n************************Inquirebyname*************************\n\n");printf("numbernamesexagemajorgradeclassbuildingfloordormitary\n\n");printf("%6d%7s%7s%6d%8s%8d%8d%10d%7d%11d\n",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("\n\n\n\n\pressanykeytothemainmeue!!!!\n");v=getchar();return;}/*按學(xué)號查詢*/inquire_num(){charv; intnum2;structstud*p0;system("cls");printf("\n\n\nPleaseinputthenumberwhoyouwhattofind:\n\n");scanf("\n%d",&num2);p0=h;while(p0!=NULL){if(p0->num==num2){printf("\n\n****************************Inquirebynumber**************************\n\n");printf("numbernamesexagemajorgradeclassbuildingfloordormitary\n\n");printf("%6d%7s%7s%6d%8s%8d%8d%10d%7d%11d\n",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("\n\n\n\n\pressanykeytothemainmeue!!!!\n"); v=getchar();return;}/*按宿舍號查詢*/inquire_dormitary(){charv; intdormitary2;structstud*p0;system("cls");printf("\n\n\nPleaseinputthedormitarywhatyouwanttofind:\n\n");scanf("\n%d",&dormitary2);p0=h;while(p0!=NULL){if(p0->dormitary==dormitary2){printf("\n\n*********************Inquirebydormitary**********************\n\n");printf("numbernamesexagemajorgradeclassbuildingfloordormitary\n\n");printf("%6d%7s%7s%6d%8s%8d%8d%10d%7d%11d\n",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("\n\n\n\n\pressanykeytothemainmeue!!!!\n");v=getchar();return;}/*按樓層查詢*/inquire_floor(){charv; intfloor2;structstud*p0;system("cls");printf("\n\n\nPleaseinputthefloorwhatyouwanttofind:\n\n");scanf("%d",&floor2);p0=h;while(p0!=NULL){if(p0->floor==floor2){printf("\n\n*************************Inquirebyfloor**************************\n\n");printf("numbernamesexagemajorgradeclassbuildingfloordormitary\n\n");printf("%6d%7s%7s%6d%8s%8d%8d%10d%7d%11d\n",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("\n\n\n\n\pressanykeytothemainmeue!!!!\n");v=getchar();return;}/*按宿舍樓查詢*/inquire_building(){charv; intbuilding2;structstud*p0;system("cls");printf("\n\n\nPleaseinputthebuildingwhoyouwhattofind:\n\n");scanf("%d",&building2);p0=h;while(p0!=NULL){if(p0->building==building2){printf("\n\n***************************Inquirebybuilding*****************************\n\n");printf("numbernamesexagemajorgradeclassbuildingfloordormitary\n\n");printf("%6d%7s%7s%6d%8s%8d%8d%10d%7d%11d\n",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("\n\n\n\n\pressanykeytothemainmeue!!!!\n");v=getchar();return;}/*查詢模塊*/inquire_message(){intchoice;do{system("cls");printf("\n\n\n~~~~~~~~InquireMessage~~~~~~~~\n\n");printf("1.Inquirebyname\n\n");printf("2.Inquirebynumber\n\n");printf("3.Inquirebydorminary\n\n");printf("4.Inquirebyfloor\n\n");printf("5.Inquirebybuilding\n\n");printf("0.Returnthemainmenu\n\n");printf("Pleasechoice(0-5):");scanf("%d",&choice);switch(choice){case1:inquire_name();break;case2:inquire_num();break;case3:inquire_dormitary();break;case4:inquire_floor();break;case5:inquire_building();break;case0:break;}}while(choice!=0);}/*按學(xué)號排序*/sort_num(){structstud*p0,*m,*n,*q;structstuds1;p0=h;system("cls");printf("\n\n***************Sortbynumber*************\n\n");while((p0->next)!=NULL)/*此循環(huán)用于控制頭指針*/{q=p0->next;while(q!=NULL)/*此循環(huán)用于控制第二指針*/{if((p0->num)>(q->num)){m=q->next;n=p0->next;s1=*p0;*p0=*q;*q=s1;q->next=m;/*使上面變化對p0和q不影響*/p0->next=n;}q=q->next;}p0=p0->next;}}/*按宿舍排序*/sort_dormitary(){structstud*p0,*m,*n,*q;structstuds2;p0=h;system("cls");printf("\n\n*****************Sortbydormitary****************\n\n");while((p0->next)!=NULL){q=p0->next;while(q!=NULL){if((p0->dormitary)>(q->dormitary)){m=q->next;n=p0->next;s2=*p0;*p0=*q;*q=s2;q->next=m;p0->next=n;}q=q->next;}p0=p0->next;}}/*按樓層排序*/sort_floor(){structstud*p0,*m,*n,*q;structstuds3;p0=h;system("cls");printf("\n\n*****************Sortbyfloor****************\n\n");while((p0->next)!=NULL){q=p0->next;while(q!=NULL){if((p0->floor)>(q->floor)){m=q->next;n=p0->next;s3=*p0;*p0=*q;*q=s3;q->next=m;p0->next=n;}q=q->next;}p0=p0->next;}}/*按宿舍樓排序*/sort_building(){structstud*p0,*m,*n,*q;structstuds4;p0=h;system("cls");printf("\n\n*****************Sortbybuilding****************\n\n");while((p0->next)!=NULL){q=p0->next;while(q!=NULL){if((p0->building)>(q->building)){m=q->next;n=p0->next;s4=*p0;*p0=*q;*q=s4;q->next=m;p0->next=n;}q=q->next;}p0=p0->next;}}/*用于輸出排序的模塊*/output(structstud*p){charv; p=h;printf("numbernamesexagemajorgradeclassbuildingfloordormitary\n\n");while(p!=NULL){printf("%6d%7s%7s%6d%8s%8d%8d%10d%7d%11d\n",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("\n\n\n\n\pressanykeytothemainmeue!!!!\n");v=getchar();return;}/*排序模塊*/sort_message(){intchoice;do{system("cls");printf("\n\n\n~~~~~~~~~~~~~~~Sortmessage~~~~~~~~~~~~~~~\n\n");printf("1.Sortbynumber\n\n");printf("2.Sortbydormitary\n\n");printf("3.Sortbyfloor\n\n");printf("4.Sortbybuilding\n\n");printf("0.Returnthemainmenu\n\n");printf("Pleasechoice(0-4):");scanf("%d",&choice);switch(choice){case1:sort_num();output(h);break;/*調(diào)用output_message()使排好的數(shù)據(jù)輸出*/case2:sort_dormitary();output(h);break;case3:sort_floor();output(h);break;case4:sort_building();output(h);break;case0:break;}}while(choice!=0);}/*按宿舍號統(tǒng)計(jì)*/count_dormitary(){charv; structstud*p;intdor;inti=0;system("cls");printf("\n\nPleaseinputthedormitarywhatyouwanttocount:\n");scanf("%d",&dor);system("cls");printf("\n\n*************************Countbydormitary***********************************\n");printf("\n\nnumbernamesexagemajorgradeclassbuildingfloordormitary\n\n");p=h;while(p!=NULL){if(p->dormitary==dor){printf("%6d%7s%7s%6d%8s%8d%8d%10d%7d%11d\n",p->num,p->name,p->sex,p->age,p->major,p->grade,p->classes,p->building,p->floor,p->dormitary);i++;}p=p->next;}printf("\nThetotal:%d",i);fflush(stdin);printf("\n\n\n\n\pressanykeytothemainmeue!!!!\n");v=getchar();return;}/*按樓層統(tǒng)計(jì)*/count_floor(){charv; structstud*p;intflo;inti=0;system("cls");printf("\n\nPleaseinputthefloorwhatyouwanttocount:\n");scanf("%d",&flo);system("cls");printf("\n\n*******************************Countbyfloor********************************\n");printf("\n\nnumbernamesexagemajorgradeclassbuildingfloordormitary\n\n");p=h;while(p!=NULL){if(p->floor==flo){printf("%6d%7s%7s%6d%8s%8d%8d%10d%7d%11d\n",p->num,p->name,p->sex,p->age,p->major,p->grade,p->classes,p->building,p->floor,p->dormitary);i++;}p=p->next;}printf("\nThetotal:%d",i);fflush(stdin);printf("\n\n\n\n\pressanykeytothemainmeue!!!!\n");v=getchar();return;}/*按宿舍樓統(tǒng)計(jì)*/count_building(){charv; structstud*p;intbui;inti=0;system("cls");printf("\n\nPleaseinputthebuildingwhatyouwanttocount:\n");scanf("%d",&bui);system("cls");printf("\n\n*******************************Countbybuilding********************************\n");printf("\n\nnumbernamesexagemajorgradeclassbuildingfloordormitary\n\n");p=h;while(p!=NULL){if(p->building==bui)

溫馨提示

  • 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論