宿舍管理查询系统课程设计C语言 完整Word文档下载推荐.docx
《宿舍管理查询系统课程设计C语言 完整Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《宿舍管理查询系统课程设计C语言 完整Word文档下载推荐.docx(16页珍藏版)》请在冰豆网上搜索。
4)查询:
按姓名查询、学号查询、房号查询
三、模块图与流程图:
模块图:
流程图:
四、程序清单:
#include<
conio.h>
#include<
stdio.h>
stdlib.h>
ctype.h>
string.h>
typedefstruct
{
charnum[10];
charname[20];
introomID;
}Student;
Studentstu[80];
intmenu_select()
charc;
do{
printf("
departmentmanagement\n"
);
1.enterinformation\n"
2.showalltheinformation|\n"
3.sort\n"
4.selectinformation|\n"
0.Quit|\n"
\n"
pleaseenteryourchoice:
c=getchar();
}while(c<
'
0'
||c>
4'
return(c-'
}
intInput(Studentstud[],intn)
{inti=0;
charsign,x[10];
while(sign!
='
n'
&
sign!
N'
)
studentnumber:
scanf("
%s"
stud[n+i].num);
name:
stud[n+i].name);
roomID:
%d"
&
stud[n+i].roomID);
gets(x);
areyouagain?
(Y/N)\n"
%c"
sign);
i++;
return(n+i);
voidDisplay(Studentstud[],intn)
inti;
studentnumber,name,roomID"
for(i=1;
i<
n+1;
i++)
\t\t\t%-16s%-15s%d\n"
stud[i-1].num,stud[i-1].name,stud[i-1].roomID);
if(i>
1&
i%10==0)
system("
pause"
voidSort_by_num(Studentstud[],intn)
{inti,j,*p,*q,s;
chart[10];
for(i=0;
n-1;
for(j=0;
j<
n-1-i;
j++)
if(strcmp(stud[j].num,stud[j+1].num)>
0)
{strcpy(t,stud[j+1].num);
strcpy(stud[j+1].num,stud[j].num);
strcpy(stud[j].num,t);
strcpy(t,stud[j+1].name);
strcpy(stud[j+1].name,stud[j].name);
strcpy(stud[j].name,t);
p=&
stud[j+1].roomID;
q=&
stud[j].roomID;
s=*p;
*p=*q;
*q=s;
Display(stu,n);
voidSort_by_name(Studentstud[],intn)
if(strcmp(stud[j].name,stud[j+1].name)>
voidSort_by_room(Studentstud[],intn)
if(stud[j].roomID>
stud[j+1].roomID)
voidQuery_a_record_by_num(Studentstud[],intn)
chars[20];
inti=0;
pleaseentersutudentnumber:
s);
while(strcmp(stud[i].num,s)!
=0&
n)i++;
if(i==n)
{printf("
noinformation\n"
return;
his(her)number:
%s\n"
stud[i].name);
stud[i].num);
his(her)roomID:
%d\n"
stud[i].roomID);
voidQuery_a_record_by_name(Studentstud[],intn)
enterthename:
while(strcmp(stud[i].name,s)!
voidQuery_a_record_by_room(Studentstud[],intn)
ints;
pleaseroomid:
"
s);
while(stud[i].roomID==s)i++;
voidWritetoText(Studentstud[],intn)
{
FILE*fp;
if((fp=fopen("
stu.txt"
"
w"
))==NULL)
fileopenfailed\n"
}
fprintf(fp,"
n);
while(i<
n)
%-16s%-15s%d\n"
stud[i].num,stud[i].name,stud[i].roomID);
fclose(fp);
Savethefileiscomplete!
voidmain()
intn=0,i;
for(;
;
)
switch(menu_select())
case1:
pleaseenterinformation\n"
n=Input(stu,n);
break;
case2:
roominformation\n"
case3:
pleasechoosethewaytosort(1name,2studentnumber,3roomID)\n"
i);
while(i)
if(i<
1||i>
3)
what