资源描述:
《c语言学生成绩管理系统代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、c语言学生成绩管理系统代码#include#include#include#defineLENsizeof(structstu)intnum=0;structstu{charname[20];charsex[20];charcla[20];charnumber[20];intc1;intc2;intc3;floatave;floatall;structstu*next;}student;structstu*head,*pf,*pb;//求总成绩floatAll(structstu*student){
2、returnstudent->c1+student->c2+student->c3;}//求平均成绩floatAve(structstu*student){return(student->c1+student->c2+student->c3)/3;}//建立链表structstu*creat(){charnumstr[20],k;FILE*fp;if((fp=fopen("d:\wenjian.txt","ab"))==NULL){printf("ttt不能打开文件");exit(1);}while(1){pb=(structstu*)ma
3、lloc(LEN);printf("ttt输入姓名:");gets(pb->name);printf("ttt输入系别:");gets(pb->sex);printf("ttt输入班级:");gets(pb->cla);printf("ttt输入学号:");gets(pb->number);printf("ttt输入成绩1:");gets(numstr);pb->c1=atol(numstr);printf("ttt输入成绩2:");gets(numstr);pb->c2=atol(numstr);printf("t
4、tt输入成绩3:");gets(numstr);pb->c3=atol(numstr);pb->ave=Ave(pb);pb->all=All(pb);if(num==0)head=pf=pb;elsepf->next=pb;pb->next=NULL;pf=pb;fwrite(pb,LEN,1,fp);printf("ttt是否继续?(n/y)");scanf("%c",&k);getchar();num++;if(k=='n')break;elsecontinue;}fclose(fp);return(head);}//按姓名查找学生voidf
5、ind(){structstu*p,*head;FILE*fp;intz=0;charf_name[20];if((fp=fopen("d:\wenjian.txt","rb"))==NULL){printf("ttt没有数据");exit(1);}printf("ttt输入要查找的学生姓名:");scanf("%s",f_name);while(fread(&student,LEN,1,fp)==1){if(strcmp(student.name,f_name)==0){printf("-----------------------
6、--------------------------------------------------------");printf("名字=%s,系别=%s,班级=%s,学号=%s,成绩1=%d,成绩2=%d,成绩3=%d,平均成绩=%.2lf,总成绩=%.2lf",student.name,student.sex,student.cla,student.number,student.c1,student.c2,student.c3,student.ave,student.all);printf("-------------------------
7、------------------------------------------------------");z=1;break;}}fclose(fp);if(z==0)printf("ttt该学生不存在");}//按学号查找voidfindnum(){structstu*p,*head;FILE*fp;intz=0;charf_num[20];if((fp=fopen("d:\wenjian.txt","rb"))==NULL){printf("ttt没有数据");exit(1);}printf("ttt输入
8、要查找的学生学号:");scanf("%s",f_num);whi