资源描述:
《学生成绩管理系统-linxu环境下》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、#include#include#include#includestructstu*input();structstu*xinxi();structstu*chaxun(FILE*fp);structstu*xiugai(FILE*fp1,FILE*fp2);structstu*shanchu(FILE*fp1,FILE*fp2);structstu*banji();structstu*yuwen(chara[]);structstu*shuxue(chara[])
2、;structstu*yingyu(chara[]);structstu{charname[10];charnum[20];charban[5];charsex[5];intchi,eng,math;};intmain()/*******************主函数******************/{intn;while(1){printf("============欢迎使用=============");printf("=========学生成绩管理系统========");printf("1.输入学生的信息=========
3、========");printf("2.查找-修改-删除学生的信息=======");printf("3.查询班级的平均分===============");printf("4.退出程序=======================");printf("=================================");printf("=================================");printf("请输入您的选择:====>");scanf("%d%*c",&n);switch(n){ca
4、se1:input();break;case2:xinxi();break;case3:banji();break;default:exit(0);}}return0;}structstu*shanchu(FILE*fp1,FILE*fp2)//删除信息函数{structstustudent;charchar_c[20];intflag=0;printf("请输入您要删除的学生的学号:");gets(char_c);while(fread(&student,sizeof(student),1,fp1)==1){if(strcmp(studen
5、t.num,char_c)==0){flag=1;fseek(fp1,sizeof(student),1);}elsefwrite(&student,sizeof(student),1,fp2);}if(flag){printf("删除成功!!");}elseprintf("Error!!未找到您想要删除的学生的信息.");remove("/usr/wanlei/ku");rename("/usr/wanlei/ku2","/usr/wanlei/ku");printf("请输入任意符号返回首页");getchar();return0
6、;}structstu*xinxi()//查询-修改-删除信息函数{inti;FILE*fp1,*fp2;if((fp1=fopen("/usr/wanlei/ku","rw"))==NULL){printf("Error!====>Can'topensourcefile!");getchar();return0;;}if((fp2=fopen("/usr/wanlei/ku2","wb"))==NULL){printf("Error!====>Can'topenfile!");getchar();exit(0);}printf("1
7、.查询学生的信息");printf("2.修改学生的信息");printf("3.删除学生的信息");printf("4.返回首页");printf("请输入您的选择:====>");scanf("%d%*c",&i);switch(i){case1:chaxun(fp1);fclose(fp1);fclose(fp2);break;case2:xiugai(fp1,fp2);fclose(fp1);fclose(fp2);break;case3:shanchu(fp1,fp2);fclose(fp1);fclose(fp2)
8、;break;case4:return0;default:printf("输入错误!");}return0;}structstu*xiugai(FILE*fp1