欢迎来到天天文库
浏览记录
ID:14127938
大小:48.50 KB
页数:20页
时间:2018-07-26
《学生管理系统(c语言版)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、学生管理系统(c语言版)#include#include#defineN100#defineS20#definePASSWORD123456structstud_list{longnumber;charname[S];longbirth;charsex;charsubject[S];charadress[S];longdorm;}stud[N+1];intsum;/*sumofstudents*/charfname[20];/*filename*/voidopera();/**************************
2、**************************************************//***************************************************************************/voidoutput(intx)/*printonestudent-information*/{printf("t%ldt%st%ldt%ct%st%st%ld",stud[x].number,stud[x].name,stud[x].birth,stud[x].sex,stud[x].sub
3、ject,stud[x].adress,stud[x].dorm);}voidprint()/*printallstudentinformations*/{inti;printf("*************************学生信息如下*************************");for(i=0;i<=sum;i++){output(i);}printf("***************************************************************");}voidcreatfile()/*reatthefile
4、tosaveinformation*/{FILE*fp;inti;if((fp=fopen(fname,"wb"))==NULL){printf("无法创建文件!");return;}for(i=0;i5、))==NULL){printf("无法打开文件!");return;}if(fread(&stud,sizeof(structstud_list),sum,fp)!=sum){if(feof(fp))return;printf("文件读取错误!");exit(0);}fclose(fp);}/*************order*************/voidord_num()/*orderbynumber*/{inti,j;for(i=0;istud[j6、+1].number){stud[N+1]=stud[j];stud[j]=stud[j+1];stud[j+1]=stud[N+1];}print();opera();}voidord_name()/*orderbyname*/{inti,j;for(i=0;istud[j+1].name){stud[N+1]=stud[j];stud[j]=stud[j+1];stud[j+1]=stud[N+1];}print();opera();}voidord_birt()/*o7、rderbybirth*/{inti,j;for(i=0;istud[j+1].birth){stud[N+1]=stud[j];stud[j]=stud[j+1];stud[j+1]=stud[N+1];}print();opera();}voidord_sex()/*orderbysex*/{inti;for(i=0;i8、9、stud[i].sex=='M')output(i);for(i=0;i10、if(stud[i].s
5、))==NULL){printf("无法打开文件!");return;}if(fread(&stud,sizeof(structstud_list),sum,fp)!=sum){if(feof(fp))return;printf("文件读取错误!");exit(0);}fclose(fp);}/*************order*************/voidord_num()/*orderbynumber*/{inti,j;for(i=0;istud[j
6、+1].number){stud[N+1]=stud[j];stud[j]=stud[j+1];stud[j+1]=stud[N+1];}print();opera();}voidord_name()/*orderbyname*/{inti,j;for(i=0;istud[j+1].name){stud[N+1]=stud[j];stud[j]=stud[j+1];stud[j+1]=stud[N+1];}print();opera();}voidord_birt()/*o
7、rderbybirth*/{inti,j;for(i=0;istud[j+1].birth){stud[N+1]=stud[j];stud[j]=stud[j+1];stud[j+1]=stud[N+1];}print();opera();}voidord_sex()/*orderbysex*/{inti;for(i=0;i8、9、stud[i].sex=='M')output(i);for(i=0;i10、if(stud[i].s
8、
9、stud[i].sex=='M')output(i);for(i=0;i10、if(stud[i].s
10、if(stud[i].s
此文档下载收益归作者所有