#include<stdio.h>#include<stdlib.h>#include<string.h>#define max_size 30 //学生最大容量#define max_course 6 //课程最大数量typedefstruct{
//学生的信息int*grades;int number;//学号char*name;int sum_gardes;double ave_grade;} StudentTp;typedefstruct node
{
//链表结点结构体
StudentTp data;struct node *next;} LNode,*Node;voidmain(){
//函数声明voidInput_record(char**s, Node h,int&total_course,int&total_student);voidCalculate_total_average(char**s, Node h,int&total_course,int&total_student);voidCalculate_students_total_average(Node h,int&total_course,int&total_student);voidSort_in_up_order(Node h,int&total_course,int&total_student);voidSort_in_down_order(Node h,int&total_course,int&total_student);voidSort_ByNumber(Node h);voidSort_ByDictionary(Node h);voidSearch_ByNumber(Node h,int&number,int&total_course,int&total_student);voidSearch_ByName(Node h,char*name,int&total_course,int&total_student);voidStatistic_Analysis(Node h,char**s,int&total_course,int&total_student);voidList_Record(Node h,char**s,int&total_course,int&total_student);voidWrite_to_a_file(Node h,char**s,int&total_course,int&total_student);voidRead_from_a_file(char**s, Node h,int&total_course,int&total_student);int total_student =0;//用于记录已经录入的学生人数int total_course =0;//用于记录已经录入的课程数//初始化必要的信息
Node h;
h =(Node)malloc(sizeof(LNode));
h->next =NULL;//初始化头结点int i;printf("请输入课程数:");scanf("%d",&total_course);//初始化课程信息printf("请输入课程名(用空格隔开):");char**a =(char**)malloc(total_course *sizeof(char*));for(i =0; i < total_course; i++)*(a + i)=(char*)malloc(10);for(i =0; i < total_course; i++)scanf("%s",*(a + i));//菜单栏用switch-case语句实现int menu;do{
printf("********************学生成绩管理系统********************\n");printf("1.Input record\n");printf("2.Calculate total and average score of every course\n");printf("3.Calculate total and average score of every student\n");printf("4.Sort in descending order by total score of every student\n");printf("5.Sort in ascending order by total score of every student\n");printf("6.Sort in ascending order by number\n");printf("7.Sort in dictionary order by name\n");printf("8.Search by number\n");printf("9.Search by name\n");printf("10.Statistic analysis for every course\n");printf("11.List record\n");printf("12.Write to a file\n");printf("13.Read from a file\n");printf("0.Exit\n");printf("Please enter your choice:");scanf("%d",&menu);printf("********************学生成绩管理系统********************\n");switch(menu){
case1:Input_record(a, h, total_course, total_student);break;case2:if(h->next ==NULL){
printf("未录入学生信息!\n")