#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define max_size 30 //学生最大容量
#define max_course 6 //课程最大数量
typedef struct
{
//学生的信息
int *grades;
int number; //学号
char *name;
int sum_gardes;
double ave_grade;
} StudentTp;
typedef struct node
{
//链表结点结构体
StudentTp data;
struct node *next;
} LNode, *Node;
void main()
{
//函数声明
void Input_record(char **s, Node h, int &total_course, int &total_student);
void Calculate_total_average(char **s, Node h, int &total_course, int &total_student);
void Calculate_students_total_average(Node h, int &total_course, int &total_student);
void Sort_in_up_order(Node h, int &total_course, int &total_student);
void Sort_in_down_order(Node h, int &total_course, int &total_student);
void Sort_ByNumber(Node h);
void Sort_ByDictionary(Node h);
void Search_ByNumber(Node h, int &number, int &total_course, int &total_student);
void Search_ByName(Node h, char *name, int &total_course, int &total_student);
void Statistic_Analysis(Node h, char **s, int &total_course, int &total_student);
void List_Record(Node h, char **s, int &total_course, int &total_student);
void Write_to_a_file(Node h, char **s, int &total_course, int &total_student);
void Read_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)
{
case 1:
Input_record(a, h, total_course, total_student);
break;
case 2:
if (h->next == NULL)
{
printf("未录入学生信息!\n")
学生成绩管理系统的设计与实现
最新推荐文章于 2024-05-05 20:42:35 发布