


版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、WORD格式宿舍信息管理系統(tǒng)代碼如下 :#include"stdio.h"#include"stdlib.h"#include"string.h"#include "conio.h"struct record專業(yè)資料整理WORD格式char numb20;/ 學(xué)號(hào)專業(yè)資料整理WORD格式char name20;char room10;/ */ 宿舍號(hào)專業(yè)資料整理WORD格式student500;int num=0;FILE *fp;專業(yè)資料整理WORD格式int menu();/* 菜單主界面*/專業(yè)資料整理WOR
2、D格式int adduser();/* 輸入記錄*/專業(yè)資料整理WORD格式int list();int searchbyname();int searchbyroom();/* 顯示記錄 */* 按*查找 */* 按宿舍號(hào)查找*/專業(yè)資料整理WORD格式int searchbynumb();/* 按學(xué)號(hào)查找*/專業(yè)資料整理WORD格式int add();/* 添加記錄*/專業(yè)資料整理WORD格式int change();int dele();int save();/*刪除學(xué)生信息/* 刪除記錄/* 保存記錄*/*/*/專業(yè)資料整理WORD格式int exit();/* 完畢 */專業(yè)資料整理
3、WORD格式menu()/* 主界面*/專業(yè)資料整理WORD格式int i;專業(yè)資料整理WORD格式printf("*_* press any key enter menu! *_* n");getch();system("cls");/* 清屏 */printf("tt*MENU*nn");printf("tt0.輸入記錄 n");printf("tt1.顯示記錄 n");printf("tt2.按*查找 n");printf("tt3.按*查找 n")
4、;專業(yè)資料整理WORD格式printf("tt4.按學(xué)號(hào)查找 n");printf("tt5.添加記錄 n");printf("tt6.修改學(xué)生信息 n");printf("tt7.刪除記錄 n");printf("tt8.記錄保存文件 n");printf("tt9.Quitn");printf("tt* *n");printf("nEnter you choice(09):");scanf("%d",&i
5、);return i;void main()for(;)switch(menu()專業(yè)資料整理WORD格式case 0:adduser();break;/* 調(diào)用輸入函數(shù)*/專業(yè)資料整理WORD格式case 1:list();break;case 2:searchbyname();break;case 3:searchbyname();break;case 4:searchbynumb();break;case 5:add();break;case 6:change();break;case 7:dele();break;case 8:save();break;/* 調(diào)用顯示記錄函數(shù)*/* 調(diào)
6、用按*查找函數(shù)/* 調(diào)用按宿舍號(hào)查找函數(shù)/* 調(diào)用按學(xué)號(hào)查找函數(shù)/* 調(diào)用添加函數(shù)*/* 調(diào)用修改學(xué)生信息函數(shù)/* 調(diào)用刪除函數(shù) */* 調(diào)用保存函數(shù)*/*/ */*/*/專業(yè)資料整理WORD格式case 9:exit(0);專業(yè)資料整理WORD格式專業(yè)資料整理WORD格式adduser()/*輸入記錄*/專業(yè)資料整理WORD格式專業(yè)資料整理WORD格式printf("ntt*請(qǐng)輸入用戶信息*n");printf("ntt輸入學(xué)號(hào) :");scanf("%s",studentnum.numb);printf("ntt輸入*
7、:");scanf("%s",);printf("ntt輸入宿舍號(hào) :");scanf("%s",studentnum.room);num+;printf("ntt是否繼續(xù)添加"(Y/N):");專業(yè)資料整理WORD格式if (getch()='y')adduser();return(0);專業(yè)資料整理WORD格式list()/* 顯示記錄*/專業(yè)資料整理WORD格式int i;if(num!=0)專業(yè)資料整理WORD格式printf("n
8、tt*以下為宿舍信息管理系統(tǒng)所有信息*");專業(yè)資料整理WORD格式for (i=0;i<num;i+)專業(yè)資料整理WORD格式printf("ntt學(xué)號(hào):%s",studenti.numb);printf("ntt*:%s",);printf("ntt宿舍號(hào):%s",studenti.room);printf("tt");if (i+1<num)printf("ntt_");printf("ntt*");elseprintf(
9、"ntt宿舍信息管理系統(tǒng)中無(wú)任何紀(jì)錄");printf("ntt按任意鍵返回主菜單:");getch();return(0);專業(yè)資料整理WORD格式searchbyname()/* 按*查找*/專業(yè)資料整理WORD格式專業(yè)資料整理WORD格式int mark=0;int i;int a=0;printf("ntt*按*查找*");char name20;printf("ntt請(qǐng)輸入* :");scanf("%s",name);for(i=a;i<num;i+)if (strcmp(stu
10、,name)=0)專業(yè)資料整理WORD格式printf("ntt*以下是您查找的用戶信息*");printf("ntt學(xué)號(hào):%s",studenti.numb);printf("ntt*:%s",);printf("ntt宿舍號(hào):%s",studenti.room );printf("ntt*");mark+;getch();return(0);if (mark=0)printf("ntt沒(méi)有該學(xué)生的信息");printf(&qu
11、ot;ntt按任意鍵返回主菜單");getch();return(0);return(0);專業(yè)資料整理WORD格式searchbyroom()/* 按學(xué)號(hào)查找*/專業(yè)資料整理WORD格式int mark=0;int i;int a=0;專業(yè)資料整理WORD格式printf("ntt*按宿舍號(hào)查找*");專業(yè)資料整理WORD格式char numb10;專業(yè)資料整理WORD格式printf("ntt請(qǐng)輸入宿舍號(hào):");scanf("%s",room);for(i=0;i<num;i+)if (strcmp(student
12、i.room,room)=0)printf("ntt*以下是您查找的用戶信息*");printf("ntt學(xué)號(hào):%s",studenti.numb);printf("ntt*:%s",);printf("ntt宿舍號(hào):%s",studenti.room);printf("ntt*");printf("ntt按任意鍵返回主菜單:");mark+;if (i+1)<num)printf("ntt是否繼續(xù)查找一樣宿舍號(hào)的用戶信息:(y/n)
13、");專業(yè)資料整理WORD格式if (getch()='y')a=i;continue;elsereturn(0);elseprintf("ntt按任意鍵返回主菜單");getch();return(0);if(mark!=0)printf("ntt沒(méi)有一樣宿舍號(hào)的用戶紀(jì)錄");printf("ntt按任意鍵返回主菜單");getch();return(0);return(0);專業(yè)資料整理WORD格式searchbynumb()/* 按學(xué)號(hào)查找*/專業(yè)資料整理WORD格式int mark=0;int i;i
14、nt a=0;專業(yè)資料整理WORD格式printf("ntt*按學(xué)號(hào)查找*");專業(yè)資料整理WORD格式char numb10;專業(yè)資料整理WORD格式printf("ntt請(qǐng)輸入學(xué)號(hào):");專業(yè)資料整理WORD格式scanf("%s",numb);for(i=0;i<num;i+)if (strcmp(studenti.numb,numb)=0)專業(yè)資料整理WORD格式printf("ntt*以下是您查找的學(xué)生信息*");專業(yè)資料整理WORD格式printf("nttprintf("nt
15、tprintf("ntt學(xué)號(hào):%s",studenti.numb);*:%s",);宿舍號(hào):%s",studenti.room);專業(yè)資料整理WORD格式printf("ntt*");printf("ntt按任意鍵返回主菜單:");mark+;getch();return(0);if (mark=0)printf("ntt沒(méi)有該學(xué)生的信息");printf("ntt按任意鍵返回主菜單");getch();return(0);return(0);專業(yè)資
16、料整理WORD格式add()/* 添加記錄*/專業(yè)資料整理WORD格式專業(yè)資料整理WORD格式int i;if (fp=fopen("student.bin","wb")=NULL)/* 判斷文件是否翻開(kāi)*/printf("ntt文件翻開(kāi)失敗");專業(yè)資料整理WORD格式for (i=0;i<num;i+)if (fwrite(&studenti,sizeof(struct record),1,fp)!=1)/*fwrite() 數(shù)據(jù)塊的輸出將以數(shù)組studenti 為首地址的一個(gè)sizeof(struct record
17、)的大小的專業(yè)資料整理WORD格式數(shù)據(jù)塊寫(xiě)入fp 指向的文件中 */printf("ntt寫(xiě)入文件錯(cuò)誤!n");printf("ntt*請(qǐng)輸入用戶信息*n");printf("ntt輸入學(xué)號(hào) :");scanf("%s",studentnum.numb);printf("ntt輸入* :");scanf("%s",);printf("ntt輸入性別 :");scanf("%s",studentnum.sex
18、);num+;printf("ntt是否繼續(xù)添加"(Y/N):");if (getch()='y')adduser();return(0);專業(yè)資料整理WORD格式fclose(fp);/* 關(guān)閉 fp 所指向的文件*/printf("ntt宿舍信息管理系統(tǒng)文件已保存");printf("ntt按任意鍵退出程序ntt");exit(0);return(0);change()/* 按學(xué)號(hào)修改 */int i,j;char numb;scanf("%s",numb);for(i=0;i<
19、num;i+)if(strcmp(studenti.numb,numb)=0)printf("ntt*以下是您查找的用戶信息*");printf("ntt學(xué)號(hào):%s",studenti.numb);printf("ntt*:%s",);printf("ntt宿舍號(hào):%s",studenti.room);printf("ntt*");printf("ntt是否要修改 "(Y/N)n");if(getchar()='Y'|get
20、char()='y')printf("ntt*請(qǐng)輸入第 %d 位的學(xué)生信息 *",i);printf("ntt輸入學(xué)號(hào) :");scanf("%s",studentnum.numb);printf("ntt輸入* :");scanf("%s",);printf("ntt輸入宿舍號(hào) :");scanf("%s",studentnum.room);printf("ntt*");studenti=
21、studenti;printf("ntt修改成功 ");printf("ntt是否繼續(xù)修改"(y/n)");if (getch()='y' | getch()='Y')plus();return;elseprintf("ntt對(duì)不起,文件中無(wú)任何紀(jì)錄");printf("ntt按任意鍵返回主菜單");getchar();return;專業(yè)資料整理WORD格式專業(yè)資料整理WORD格式void deletebynumb()/* 按學(xué)號(hào)刪除 */int i,j;int delet
22、emark=0;/* 將刪除聯(lián)系人的數(shù)目初始化為0*/char numb20;printf("ntt請(qǐng)輸入要?jiǎng)h除學(xué)生學(xué)號(hào):");scanf("%s",numb);if(num=0)/*num 為 0 說(shuō)明宿舍信息管理系統(tǒng)中還沒(méi)有輸入聯(lián)系人*/專業(yè)資料整理WORD格式printf("ntt對(duì)不起,文件中無(wú)任何紀(jì)錄");printf("ntt按任意鍵返回主菜單");getch();return;for (i=0;i<num;i+)if (strcmp(studenti.numb,numb)=0)printf(&q
23、uot;ntt以下是您要?jiǎng)h除的學(xué)生紀(jì)錄:");printf("ntt學(xué)號(hào):%s",studenti.numb);printf("ntt*:%s",);printf("ntt性別:%s",studenti.room);printf("tt");printf("ntt是否刪除 "(y/n)");if (getch()='y')專業(yè)資料整理WORD格式for (j=i;j<num-1;j+)studentj=studentj+1;nu
24、m-;deletemark+;printf("ntt刪除成功 ");printf("ntt是否繼續(xù)刪除if (getch()='y')deletebynumb();return;elsereturn;continue;/* 跳出 forif (deletemark=0)/* 將要?jiǎng)h除的學(xué)生的后一位賦值給要?jiǎng)h除的學(xué)生*/* 宿舍信息管理系統(tǒng)中的學(xué)生數(shù)目減少1*/* 刪除的聯(lián)系人增加1*/"(y/n)");/* 輸入 y 值,繼續(xù)調(diào)用按學(xué)號(hào)函數(shù)刪除*/* 否那么,返回值 */循環(huán),立即轉(zhuǎn)向計(jì)算表達(dá)式3,對(duì)循環(huán)控制變量增量或減量/*
25、假設(shè)刪除的學(xué)生數(shù)目為0,那么說(shuō)明沒(méi)有刪除學(xué)生信息管理系*/專業(yè)資料整理WORD格式統(tǒng)里的學(xué)生*/專業(yè)資料整理WORD格式printf("ntt沒(méi)有該學(xué)生的紀(jì)錄");printf("ntt是否繼續(xù)刪除"(y/n)");if (getch()='y')/* 輸入 y 值,繼續(xù)調(diào)用按學(xué)號(hào)函數(shù)刪除deletebynumb();return;*/專業(yè)資料整理WORD格式專業(yè)資料整理WORD格式void deletebyname()/* 按*刪除*/專業(yè)資料整理WORD格式int a=0;int findmark=0;int i,j;int
26、 deletemark=0;char name20;專業(yè)資料整理WORD格式printf("ntt請(qǐng)輸入要?jiǎng)h除學(xué)生*:");scanf("%s",name);for (i=a;i<num;i+)if (strcmp(,name)=0)printf("ntt以下是您要?jiǎng)h除的學(xué)生紀(jì)錄:");findmark+;printf("ntt_");printf("ntt學(xué)號(hào):%s",studenti.numb);printf("ntt*:%s",stude
27、);printf("ntt性別:%s",studenti.sex);printf("ntt出生日期:%s",studenti.birth);printf("ntt學(xué)位: %s",studenti.degr);printf("ntt職務(wù): %s",studenti.duty);printf("ntt: %s",studenti.tel);printf("ntt_");printf("ntt是否刪除 "(y/n)");if (getchar()='y')for (j=i;j<num-1;j+)studentj=studentj+1;num-;deletemark+;專業(yè)資料整理WORD格式printf("nttprintf("ntt刪除成功 ");是否繼續(xù)刪除"(y/n
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年大學(xué)試題(醫(yī)學(xué))-急救護(hù)理學(xué)歷年參考題庫(kù)含答案解析(5套典型考題)
- 2025年大學(xué)試題(農(nóng)學(xué))-植物與生產(chǎn)環(huán)境歷年參考題庫(kù)含答案解析(5套典型考題)
- 2025年國(guó)家開(kāi)放大學(xué)(電大)-土木工程(建筑管理)歷年參考題庫(kù)含答案解析(5套典型考題)
- 2025年衛(wèi)生資格(中初級(jí))-護(hù)士定期考核歷年參考題庫(kù)含答案解析(5套典型題)
- 2025年醫(yī)學(xué)高級(jí)職稱-燒傷外科學(xué)(醫(yī)學(xué)高級(jí))歷年參考題庫(kù)含答案解析(5套典型題)
- 2025年企業(yè)文化企業(yè)建設(shè)知識(shí)競(jìng)賽-大慶精神鐵人精神知識(shí)競(jìng)賽歷年參考題庫(kù)含答案解析(5套典型考題)
- 2025年業(yè)務(wù)知識(shí)崗位知識(shí)競(jìng)賽-導(dǎo)游服務(wù)知識(shí)競(jìng)賽歷年參考題庫(kù)含答案解析(5套典型考題)
- 2025年專業(yè)技術(shù)人員繼續(xù)教育公需科目-形象塑造與禮儀修養(yǎng)繼續(xù)教育歷年參考題庫(kù)含答案解析(5套典型考題)
- 2024-2025學(xué)年三年級(jí)英語(yǔ)下冊(cè)Unit1 -Unit8默寫(xiě)紙+知識(shí)清單(含默寫(xiě)紙)
- 企業(yè)注資 協(xié)議書(shū)
- 2025屆山西中考語(yǔ)文真題試卷【含答案】
- 語(yǔ)言接觸與混合語(yǔ)現(xiàn)象-洞察及研究
- Q-GDW11628-2016新能源消納能力計(jì)算導(dǎo)則
- 維修工崗位考試題及答案
- 2026高考地理《地理原理》復(fù)習(xí)課件
- 關(guān)于新時(shí)代遼寧省國(guó)家大學(xué)科技園建設(shè)發(fā)展思路及模式的建議
- 2025叉車?yán)碚摽荚囋囶}及答案
- 2025年廣西公需科目答案03
- 礦井托管運(yùn)營(yíng)方案(3篇)
- 《聚碳酸酯合成》課件
- 2025年中國(guó)不銹鋼寬幅網(wǎng)市場(chǎng)調(diào)查研究報(bào)告
評(píng)論
0/150
提交評(píng)論