資源描述:
《c語言程序設(shè)計 宿舍管理系統(tǒng)》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、#include#include#include#include#defineN100/*最大人數(shù)*/structstu_type/*定義一個結(jié)構(gòu)體數(shù)據(jù)類型*/{charnum[15];charname[7];intsushehao;intsex;intlocation;};structroom{intloc;intnum;intsushe;};structstu_typestu[N+1];structroomr[10];int
2、CurrentCount=0;intcount=1;voidinput()/*錄入模塊*/{inti=0;charflag='Y';FILE*fp;printf("請依據(jù)以下要求填寫學(xué)生信息:");printf("性別:男:0女:1");printf("宿舍區(qū)域:西區(qū):0東區(qū):1三里:2同大:3");printf("");fp=fopen("shuju.txt","a");printf("請輸入一個人員的相關(guān)信息(學(xué)號姓名性別宿舍區(qū)域宿舍號):");scanf("%s%s%d%d
3、%d",&stu[i].num,&stu[i].name,&stu[i].sex,&stu[i].location,&stu[i].sushehao);r[count].num++;r[count].loc=stu[i].location;r[count].sushe=stu[i].sushehao;//count++;fprintf(fp,"%s%s%d%d%d",stu[i].num,stu[i].name,stu[i].sex,stu[i].location,stu[i].sushehao);pr
4、intf("(*^__^*)信息已成功保存!!!");printf("是否繼續(xù)(Y/N):");scanf("%s",&flag);CurrentCount++;i++;while((flag=='Y')
5、
6、(flag=='y')){if(flag==N){printf("o(>﹏<)o人數(shù)已達上限,不能添加?。?!");flag='N';}else{printf("請輸入一個人員的相關(guān)信息(學(xué)號姓名性別宿舍區(qū)域宿舍號):");scanf("%s%s%d%d%d",&stu[i
7、].num,&stu[i].name,&stu[i].sex,&stu[i].location,&stu[i].sushehao);fprintf(fp,"%s%s%d%d%d",stu[i].num,stu[i].name,stu[i].sex,stu[i].location,stu[i].sushehao);if((stu[i].sushehao==stu[i-1].sushehao)&&(stu[i].location==stu[i-1].location)){r[count].num++;pri
8、ntf("%d",r[count].num);//r[count].loc=stu[i].location;}else{count++;r[count].num++;r[count].loc=stu[i].location;r[count].sushe=stu[i].sushehao;}printf("信息已成功保存!!!");printf("是否繼續(xù)(Y/N):");scanf("%s",&flag);CurrentCount++;i++;}}fclose(fp);
9、}voidsearch1()/*按姓名查詢模塊*/{inti;charname[20];charflag='Y';while((flag=='Y')
10、
11、(flag=='y')){printf("請輸入一個待查學(xué)員的姓名:");scanf("%s",name);i=CurrentCount-1;while(strcmp(stu[i].name,name)!=0){i--;}if(i==-1)printf("o(>﹏<)o查無此人?。?!");else{printf("此人詳細信息如下:");
12、printf("%s%s%d%d%d",stu[i].num,stu[i].name,stu[i].sex,stu[i].location,stu[i].sushehao);}printf("是否繼續(xù)(Y/N):");scanf("%s",&flag);}}voidsearch2()/*按學(xué)號查詢模塊*/{charnum[15];intflag='Y',i;while((flag=='Y')
13、
14、(flag=='y')){printf("