资源描述:
《学生信息管理系统c语言(运行无误》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#include#include#defineN30structdate{intyear;charmonth;charday;};structstudent{charno[9];charname[9];charsex[3];structdatebirthday;intscore[4];};intmenu(){intopt;printf("********************学生信息管理*********************");printf(
2、"<1显示学生信息");printf("<2显示按姓名排序学生信息");printf("<3显示按总分排序学生信息");printf("<4按学号查询学生信息和平均分数");printf("<5按姓名查询学生信息和平均分数");printf("<6查个门课平均分数");printf("<7查男女学生数和总人数");printf("<8显示学生信息表");printf("<0退出");printf("选择序号(,2,3,4,5,6,7,8,0):");scanf("%d",&opt);retu
3、rnopt;}voidbuiltxinxi(structstudentstu[],int*n)/*建立学生信息*/{inti;FILE*fp;if((fp=fopen("D:\studf.txt","r"))==NULL){printf("can'topenstudf.txt!");exit(1);}for(i=0;!feof(fp);i++){(*n)++;if(*n>N){printf("超出班级学生人数!");return;}fscanf(fp,"%s%s%s%d%d%d%d%d%d",&stu[i].no,&
4、stu[i].name,&stu[i].sex,&stu[i].birthday.year,&stu[i].birthday.month,&stu[i].birthday.day,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);stu[i].score[3]=stu[i].score[0]+stu[i].score[1]+stu[i].score[2];}fclose(fp);}voidprintscores(structstudent*ss[],intn)/*显示按总分
5、排序后的学生信息*/{inti;printf("**********按总分排序后的学生信息**********");printf("");printf("学号姓名性别年月日数学英语C总分");for(i=0;ino,ss[i]->name,ss[i]->sex,ss[i]->birthday.year,ss[i]->birthday.month,ss[i]->birthday.day,ss
6、[i]->score[0],ss[i]->score[1],ss[i]->score[2],ss[i]->score[3]);}}voidnosort(structstudent*pstu,intn)/*按学号排序—简单比较排序法*/{structstudenttemp;inti,j;for(i=0;i0){temp=pstu[i];pstu[i]=pstu[j];pstu[j]=temp;}}voidnam
7、esort(structstudent*ns[],intn)/*按姓名递增冒泡排序*/{structstudent*temp;inti,j;for(i=0;iname,ns[j+1]->name)>0){temp=ns[j];ns[j]=ns[j+1];ns[j+1]=temp;}}voidscoresot(structstudent*ss[],intn)/*按总分递减选择排序*/{structstudent*temp;inti,j;f
8、or(i=0;iscore[3]score[3]){temp=ss[j];ss[j]=ss[j+1];ss[j+1]=temp;}}}voidprintstu(structst