![學(xué)生宿舍管理系統(tǒng)源代碼樣本_第1頁](http://file4.renrendoc.com/view12/M07/27/08/wKhkGWX1RDuAD6SnAADTzjILsRo276.jpg)
![學(xué)生宿舍管理系統(tǒng)源代碼樣本_第2頁](http://file4.renrendoc.com/view12/M07/27/08/wKhkGWX1RDuAD6SnAADTzjILsRo2762.jpg)
![學(xué)生宿舍管理系統(tǒng)源代碼樣本_第3頁](http://file4.renrendoc.com/view12/M07/27/08/wKhkGWX1RDuAD6SnAADTzjILsRo2763.jpg)
![學(xué)生宿舍管理系統(tǒng)源代碼樣本_第4頁](http://file4.renrendoc.com/view12/M07/27/08/wKhkGWX1RDuAD6SnAADTzjILsRo2764.jpg)
![學(xué)生宿舍管理系統(tǒng)源代碼樣本_第5頁](http://file4.renrendoc.com/view12/M07/27/08/wKhkGWX1RDuAD6SnAADTzjILsRo2765.jpg)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
數(shù)據(jù)構(gòu)造課程設(shè)計(jì)源代碼設(shè)計(jì)題目:學(xué)生宿舍管理系統(tǒng)院系:計(jì)算機(jī)學(xué)院班級(jí):軟件1501組別:六組長:周佳理組員:韓壯壯陳義安起止日期:12月20日~12月24日指引教師:韓麗娜源代碼:#define_CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<string.h>voidAppendNode(longstudentID,charstudentName[15],charroomNumber[4],charbedNumber[4]);//向鏈表中添加數(shù)據(jù)voidDisplayNode(structlink*head);//打印鏈表中數(shù)據(jù)voidDisplay(structlink*head);//表頭格式控制voidDeleteMemory(structlink*head);//刪除鏈表所占用內(nèi)存voidSave();//保存數(shù)據(jù)voidOpen();//打開數(shù)據(jù)voidFindID();//按學(xué)號(hào)查找學(xué)生voidFindName();//按姓名查找學(xué)生voidInsertNodeNumber(longstudentID,charstudentName[15],charroomNumber[4],charbedNumber[4]);//按學(xué)號(hào)從小到大排序voidNumberSorting();//排序voidMenu();//菜單控制模塊功能代碼://主函數(shù)intmain(){ longstudentID; charstudentName[15]; charroomNumber[4]; charbedNumber[4];//定義要輸入學(xué)生信息變量; charc; intmenu;//保存要進(jìn)行選項(xiàng); while(1){ system("pause"); Menu(); printf("請(qǐng)輸入要進(jìn)行操作:"); scanf("%d",&menu); switch(menu){ case0: exit(0);break; case1: printf("請(qǐng)輸入Y或y來添加數(shù)據(jù)\n"); scanf("%c",&c); while(c=='y'||c=='Y'){ printf("請(qǐng)輸入學(xué)生學(xué)號(hào):"); scanf("%lld",&studentID); printf("請(qǐng)輸入學(xué)生姓名:"); scanf("%s",&studentName); printf("請(qǐng)輸入房間號(hào):"); scanf("%s",&roomNumber); printf("請(qǐng)輸入床位號(hào):"); scanf("%s",&bedNumber); AppendNode(studentID,studentName,roomNumber,bedNumber); printf("請(qǐng)輸入Y或y來添加數(shù)據(jù)\n"); scanf("%c",&c); } Display(head);break; case2: FindID();break; case3: FindName();break; case4: Display(head);//顯示信息break; case5: NumberSorting(); Display(head1);//排序后學(xué)生信息 head1=NULL;break; case6: Save();break; case7: Open();break; default: printf("輸入有誤!請(qǐng)重新輸入");break; } } DeleteMemory(head); DeleteMemory(head1); system("pause"); return0;}//菜單voidMenu(){ system("cls");//清屏操作; printf("\n\n\n\n\n"); printf("\t\t|.......學(xué)生宿舍管理系統(tǒng)..............|\n"); printf("\t\t|\t0.退出|\n"); printf("\t\t|\t1.添加學(xué)生住宿信息|\n"); printf("\t\t|\t2.查找學(xué)生(按學(xué)號(hào))信息|\n"); printf("\t\t|\t3.查找學(xué)生(按姓名)信息|\n"); printf("\t\t|\t4.顯示學(xué)生信息|\n"); printf("\t\t|\t5.按學(xué)號(hào)排序|\n"); printf("\t\t|\t6.保存信息|\n"); printf("\t\t|\t7.打開信息|\n"); printf("\t\t|.......學(xué)生宿舍管理系統(tǒng)..............|\n");}//表頭格式控制voidDisplay(structlink*head){ printf("-----------------------------------------------------------\n"); printf("學(xué)號(hào)姓名宿舍號(hào)床號(hào)\n"); printf("-----------------------------------------------------------\n");DisplayNode(head);}數(shù)據(jù)模塊功能代碼://定義構(gòu)造體typedefstructstudent{ longstudentID;//學(xué)號(hào) charstudentName[15];//姓名 charroomNumber[4];//房間號(hào) charbedNumber[4];//床號(hào)}STU;//初始化鏈表structlink{ STUstudent; structlink*next;};structlink*head=NULL;//保存輸入學(xué)生信息數(shù)據(jù)structlink*head1=NULL;//保存排序后學(xué)生信息數(shù)據(jù)//添加數(shù)據(jù)voidAppendNode(longstudentID,charstudentName[15],charroomNumber[4],charbedNumber[4]){ structlink*p=NULL,*pr=head; p=(structlink*)malloc(sizeof(structlink)); if(p==NULL){ printf("申請(qǐng)內(nèi)存失敗");return; } if(head==NULL){ head=p; } else{ while(pr->next!=NULL){ pr=pr->next; } pr->next=p; } p->student.studentID=studentID; strcpy(p->student.studentName,studentName); strcpy(p->student.roomNumber,roomNumber); strcpy(p->student.bedNumber,bedNumber); p->next=NULL;return;}//打印數(shù)據(jù)voidDisplayNode(structlink*head){ structlink*p=head; if(p==NULL){ return; } printf("%lld%15s%13s%13s",p->student.studentID,p->student.studentName,p->student.roomNumber,p->student.bedNumber); printf("\n");p=p->next;DisplayNode(p);}//保存鏈表中數(shù)據(jù)voidSave(){ FILE*fp; structlink*p=head; fp=fopen("demo.txt","w"); if(fp==NULL){ printf("打開文獻(xiàn)失敗");return; } while(p!=NULL){ fprintf(fp,"%20lld%15s%5s%4s",p->student.studentID,p->student.studentName,p->student.roomNumber,p->student.bedNumber); p=p->next; } fclose(fp);return;}//將文獻(xiàn)中獲得數(shù)據(jù)寫入到鏈表中voidOpen(){ fflush(stdin); fflush(stdout); longstudentID; charstudentName[15]; charroomNumber[4]; charbedNumber[4]; FILE*fp;charc; fp=fopen("demo.txt","a+"); if(fp==NULL){ printf("文獻(xiàn)打開失敗");return; } while((c=fgetc(fp))!=EOF){ fscanf(fp,"%20lld",&studentID); fscanf(fp,"%15s",studentName); fscanf(fp,"%5s",roomNumber); fscanf(fp,"%4s",bedNumber); AppendNode(studentID,studentName,roomNumber,bedNumber); } fclose(fp);}功能模塊功能代碼://排序函數(shù)voidNumberSorting(){ structlink*p=head; structlink*p1=head1; intsum=0; if(p==NULL){ printf("沒有數(shù)據(jù),無法排序");return; } while(p!=NULL){ InsertNodeNumber(p->student.studentID,p->student.studentName,p->student.roomNumber,p->student.bedNumber);p=p->next; }}//按學(xué)號(hào)從小到大排序voidInsertNodeNumber(longstudentID,charstudentName[15],charroomNumber[4],charbedNumber[4]){ structlink*pr=head1,*p=head1,*temp=NULL; p=(structlink*)malloc(sizeof(structlink)); if(p==NULL){ printf("內(nèi)存申請(qǐng)失敗");return; } p->next=NULL; p->student.studentID=studentID; strcpy(p->student.studentName,studentName); strcpy(p->student.roomNumber,roomNumber); strcpy(p->student.bedNumber,bedNumber); if(head1==NULL){ head1=p; } else{ while(pr->student.studentID<studentID&&pr->next!=NULL){ temp=pr;pr=pr->next; } if(pr->student.studentID>=studentID){ if(pr==head1){ p->next=head1;head1=p; } else{ pr=temp;p->next=pr->next;pr->next=p; } } else{ pr->next=p; } }}//刪除鏈表所占用內(nèi)存voidDeleteMemory(structlink*head){ structlink*p=head,*pr=NULL; while(p!=NULL){ pr=p;p=p->next;free(pr); } }//按學(xué)號(hào)查找學(xué)生voidFindID(){ structlink*p=head; longstudentID=0; if(head==NULL){ printf("沒有數(shù)據(jù)查找");return; } printf("請(qǐng)輸入你要查找學(xué)生學(xué)號(hào):"); scanf("%lld",&studentID); while(studentID!=p->student.studentID&&p->next!=NULL){ p=p->next; } if(p->student.studentID==studentID){ printf("-----------------------------------------------------------\n"); printf("學(xué)號(hào)姓名宿舍號(hào)床號(hào)\n"); printf("-----------------------------------------------------------\n"); printf("%lld%15s%13s%13s",p->student.studentID,p->student.studentName,p->student.roomNumber,p->student.bedNumber);; } else{ printf("沒有你要查找數(shù)據(jù)"); }
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度體育賽事贊助合同范本-@-10
- 2025年滌綸披巾項(xiàng)目可行性研究報(bào)告
- 2025年反絨革項(xiàng)目可行性研究報(bào)告
- 2025年度綠色建筑節(jié)能改造施工合同答辯狀
- 2025年度建筑節(jié)能工程施工合同規(guī)范范本
- 2025年素牛排項(xiàng)目投資可行性研究分析報(bào)告
- 2025年度大數(shù)據(jù)股份分配與智慧城市建設(shè)協(xié)議
- 2024-2030年中國舞臺(tái)煙霧機(jī)行業(yè)發(fā)展前景預(yù)測(cè)及投資策略研究報(bào)告
- 2024年車身廣告行業(yè)市場(chǎng)深度分析及發(fā)展前景預(yù)測(cè)報(bào)告
- 2025年不飽和樹脂設(shè)備行業(yè)深度研究分析報(bào)告
- 《工程電磁場(chǎng)》配套教學(xué)課件
- 遼寧省錦州市各縣區(qū)鄉(xiāng)鎮(zhèn)行政村村莊村名居民村民委員會(huì)明細(xì)及行政區(qū)劃代碼
- 改革開放的歷程(終稿)課件
- 職位管理手冊(cè)
- IPQC首檢巡檢操作培訓(xùn)
- 餐飲空間設(shè)計(jì)課件ppt
- 肉制品加工技術(shù)完整版ppt課件全套教程(最新)
- (中職)Dreamweaver-CC網(wǎng)頁設(shè)計(jì)與制作(3版)電子課件(完整版)
- 行政人事助理崗位月度KPI績效考核表
- 紀(jì)檢監(jiān)察機(jī)關(guān)派駐機(jī)構(gòu)工作規(guī)則全文詳解PPT
- BP-2C 微機(jī)母線保護(hù)裝置技術(shù)說明書 (3)
評(píng)論
0/150
提交評(píng)論