学生成绩管理系统的设计与实现

#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")
  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值