关于#c语言#的,请各位专家解答!

  1. 编写程序 c5-3-1.c, 程序所实现的功能是:学生成绩管理系统(V1.0 版)
    文件 score.txt 中存放若干同学的学号及高数、英语、C 语言 3 门课的成绩,格式如下:
    1001 90 80 70
    1002 85 78 80
    1003 60 70 76

    img


#include<stdio.h>
int main()
{
    int num,math,eng,computer;
    double p;
    FILE *fp,*fp2;
    fp=fopen("score.txt","r+");
    fp2=fopen("score_avg.txt","w");
    printf("学号\t高数\t英语\tC语言\t平均分\n");
    fprintf(fp2,"学号\t高数\t英语\tC语言\t平均分\n");
    while(!feof(fp))
    {
        fscanf(fp,"%d%d%d%d",&num, &math,&eng,&computer);
        p=(math+eng+computer)/3.0;
        printf("%d\t%d\t%d\t%d\t%.2lf\n",num,math,eng,computer,p);
        fprintf(fp2,"%d\t%d\t%d\t%d\t%.2lf\n",num,math,eng,computer,p);
    }
    fclose(fp);
    fclose(fp2);
    return 0;
}

先建一个score.txt文件夹哦亲。