C语言实现学生成绩信息的读取和处理

功能

读取文件中关于学生姓名、专业、成绩等信息,计算其总成绩和各专业的学生数、平均成绩,并输出。

效果

读取文件:

小红 通信 84 88 84
小明 通信 77 65 58
张三 通信 89 93 95
李四 软件 88 91 94
钱五 软件 95 49 98
王五 网络 71 94 88
大明 网络 45 54 45

程序运行结果:
程序运行结果

源代码

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#define IsCommu(x) (strcmp((x)->major, "通信") == 0) //利用宏判断专业类型
#define IsNet(x) (strcmp((x)->major, "网络") == 0)
#define IsSoft(x) (strcmp((x)->major, "软件") == 0)

struct student //存放学生数据的结构体
{
   
    char name[100];
    char major[100];
    int eng;
    int alg;
    int c;
    int sum;
} *p = NULL;

struct calc //存放专业统计数据的结构体
{
   
    char major[100];
    int snum;
    int avg;
} Commu = {
   "通信", 0, 0}, Net = {
   "网络", 0, 0}, Soft = {
   "软件", 0, 0};

int ReadStudentInfo(const char *filename) //打开文件,读取数据
{
   
    int sum = 0, i;
    char name[100]
  • 3
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值