该程序包括以下功能:
1.录入每个学生的学号、姓名和各科考试成绩
2.计算每门课程的总分和平均分
3.计算每个学生的总分和平均分
4.按每个学生的总分由高到低排出名次表
5.按每个学生的总分由低到高排出名次表
6.按学号由小到大排出成绩表
7.按姓名的字典顺序排出成绩表
8.按学号查询学生排名及其考试成绩
9.按姓名查询学生排名及其考试成绩
10.按优秀(90-100)、良好(80-89)、中等(70-79)、及格(60-69)、不及格(0-59)5个类别,对每门课程分别统计每个类别的人数以及所占的百分比
11.输出每个学生的学号、姓名、各科考试成绩,以及每门课程的总分和平均分
12.将每个学生的纪录信息写入文件
13.从文件中读出每个学生的纪录信息并显示
#include<stdio.h>
#include<string.h>
#include<math.h>
#include "malloc.h"
#include <stdlib.h>#define MAX_LEN 10 /* 字符串最大长度 */
#define STU_NUM 30 /* 最多的学生人数 */
#define COURSE_NUM 6 /* 最多的考试科目数 */
#define LEN sizeof(struct Student)typedef struct Student
{long num; /* 每个学生的学号 */char name[MAX_LEN]; /* 每个学生的姓名 */float score[COURSE_NUM]; /* 每个学生COURSE_NUM门功课的成绩 */float sum; /* 每个学生的总成绩 */float aver; /* 每个学生的平均成绩 */struct Student *next;
}STU;int Menu(void); //创建菜单
void Print(STU *head, int n, int m); //打印函数
void AverSumofEveryStudent(STU *head, int n, int m); //计算每门课程的总分和平均分
void AverSumofEveryCourse(STU *head, int n, int m); //计算每个学生的总分和平均分
STU *SortbyScore(STU *head, int n); //按每个学生的总分由高到低排出名次表
STU *Creat(int n, int m); //创建链表并录入信息
STU *Creat1(int n, int m);
STU *SortbyScore1(STU *head, int n); //按每个学生的总分由低到高排出名次表
STU *SortbyNum(STU *head); //按学号由小到大排出成绩表
STU *SortbyName(STU *head, int n); //按姓名的字典顺序排出成绩表
void SearchbyNum(STU *head, int n, int m); //按学号查询学生排名及其考试成绩
void SearchbyName(STU *head, int n, int m); //按姓名查询学生排名及其考试成绩
void StatisticAnalysis(STU *head, int n, int m); //按类别及比例输出
void WritetoFile(STU *head, int n, int m); //将每个学生的纪录信息写入文件
STU *ReadfromFile(STU *head, int *n, int *m); //从文件中读出每个学生的纪录信息并显示int main()
{int n, m;int i;STU *head; //定义头节点head = (STU *)malloc(LEN);while (1){i = Menu();if (i == 1){system("cls"); //清屏printf("\t\t\t******************************************************************************\n");printf("\t\t\tInput student number(n<30):\n"); //输入学生数printf("\t\t\t");scanf("%d", &n);printf("\t\t\tInput course number(m<=6):\n");printf("\t\t\t");scanf("%d", &m);}switch (i){case 1:printf("\t\t\tInput student's ID, name and score:\n");head = Creat(n, m);system("cls"); //清屏break;case 2:system("cls"); //清屏AverSumofEveryStudent(head, n, m);break;case 3:system("cls"); //清屏AverSumofEveryCourse(head, n, m);break;case 4:system("cls"); //清屏printf("\n\n\n");printf("\t\t\tSort in ascending order by score:\n");head = SortbyScore(head, n);Print(head, n, m);break;case 5:system("cls"); //清屏printf("\n\n\n");printf("\t\t\tSort in ascending order by score:\n");head = SortbyScore1(head, n);Print(head, n, m);break;case 6:system("cls"); //清屏printf("\n\n\n");printf("\t\t\tSort in ascending order by number:\n");head = SortbyNum(head);Print(head, n, m);break;case 7:system("cls"); //清屏printf("\n\n\n");printf("\t\t\tSort in dictionary order by name:\n");head = SortbyName(head, n);Print(head, n, m);break;case 8:system("cls"); //清屏printf("\n\n\n");printf("\t\t\t******************************************************************************\n"