首页 C语言——学生成绩管理

C语言——学生成绩管理

举报
开通vip

C语言——学生成绩管理#include<stdio.h>typedefstructstudent_type_tag{charnum[12];charname[8];charclassname[20];floatscore[3];floatave;}student_type;student_typestud[4];voidsave(){FILE*fp=fopen("score.txt","wb");if(fp){for(inti=0;i<4;i++){fwrite(&stu...

C语言——学生成绩管理
#include<stdio.h>typedefstructstudent_type_tag{charnum[12];charname[8];charclassname[20];floatscore[3];floatave;}student_type;student_typestud[4];voidsave(){FILE*fp=fopen("score.txt","wb");if(fp){for(inti=0;i<4;i++){fwrite(&stud[i],sizeof(student_type),1,fp);}fclose(fp);}}voiddisplay(){FILE*fp=fopen("score.txt","rb");if(fp){printf("\n------------成绩---------------");for(inti=0;i<4;i++){student_typeastud;fread(&astud,sizeof(student_type),1,fp);printf("\n%12s|%8s|%20s|%3.1f|%3.1f|%3.1f|%3.1f",astud.name,astud.name,astud.classname,astud.score[0],astud.score[1],astud.score[2],astud.ave);}fclose(fp);}}intmain(intargc,char*argv[]){for(inti=0;i<4;i++){printf("\n--输入成绩[%i/4]--\n",i+1);printf("请输入学号(最长12位):");scanf("%s",&stud[i].num);printf("请输入姓名(最长8位):");scanf("%s",&stud[i].name);printf("请输入班级(最长20位):");scanf("%s",&stud[i].classname);printf("请输入成绩1(xx.x):");scanf("%f",&stud[i].score[0]);printf("请输入成绩2(xx.x):");scanf("%f",&stud[i].score[1]);printf("请输入成绩3(xx.x):");scanf("%f",&stud[i].score[2]);stud[i].ave=(stud[i].score[0]+stud[i].score[1]+stud[i].score[2])/3;}printf("\n正在保存...");save();printf("ok");display();getchar();getchar();return0;}
本文档为【C语言——学生成绩管理】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_324624
暂无简介~
格式:doc
大小:12KB
软件:Word
页数:2
分类:工学
上传时间:2011-06-28
浏览量:199