21xrx.com
2024-09-20 05:50:09 Friday
登录
文章检索 我的文章 写文章
用C++编写学生成绩管理系统
2023-06-28 00:53:33 深夜i     --     --
C++ 成绩管理系统 学生 学科 成绩查询

学生成绩管理系统是一款非常重要的软件,因为它可以帮助学校或教育机构更好地管理学生的成绩,进而更好地评估学生的学业水平。C++作为一种高级编程语言,在实现这一管理系统方面起到非常重要的作用。本文将介绍如何使用C++编写学生成绩管理系统。

学生成绩管理系统一般包括以下几个方面的功能:学生信息的录入、查询和修改,成绩的录入、查询和修改,以及成绩统计分析等功能。下面我们将根据这几个功能来介绍如何用C++来实现。

首先,我们需要通过定义一个结构体来保存学生的信息。结构体包括学生的姓名、学号、性别、班级等基本信息。代码如下:


struct Student {

  char name[20]; // 学生姓名

  int sno; // 学生学号

  char sex; // 学生性别

  char classno[20]; // 班级编号

};

接着,我们需要定义一个数组来保存所有学生的信息。代码如下:


Student student[1000]; // 学生信息数组,最多可存储1000个学生信息

int n; // 学生总数

然后,我们需要实现录入、查询、修改学生信息的功能。代码如下:


// 录入学生信息

void input() {

  cout << "请输入学生人数:";

  cin >> n;

  for (int i = 0; i < n; i++) {

    cout << "请输入第" << i + 1 << "个学生的姓名、学号、性别和班级编号:";

    cin >> student[i].name >> student[i].sno >> student[i].sex >> student[i].classno;

  }

}

// 查询学生信息

void query() {

  int sno;

  cout << "请输入要查询的学生学号:";

  cin >> sno;

  for (int i = 0; i < n; i++) {

    if (student[i].sno == sno) {

      cout << "学生姓名:" << student[i].name << endl;

      cout << "学生学号:" << student[i].sno << endl;

      cout << "学生性别:" << student[i].sex << endl;

      cout << "班级编号:" << student[i].classno << endl;

      return;

    }

  }

  cout << "未找到该学生信息!" << endl;

}

// 修改学生信息

void modify() {

  int sno;

  cout << "请输入要修改的学生学号:";

  cin >> sno;

  for (int i = 0; i < n; i++) {

    if (student[i].sno == sno) {

      cout << "请输入学生的新姓名、学号、性别和班级编号:";

      cin >> student[i].name >> student[i].sno >> student[i].sex >> student[i].classno;

      cout << "学生信息修改成功!" << endl;

      return;

    }

  }

  cout << "未找到该学生信息!" << endl;

}

接下来,我们需要实现录入、查询、修改学生的成绩功能。代码如下:


// 录入学生成绩

void inputScore() {

  int sno;

  cout << "请输入要录入成绩的学生学号:";

  cin >> sno;

  for (int i = 0; i < n; i++) {

    if (student[i].sno == sno) {

      cout << "请输入学生的语文成绩、数学成绩和英语成绩:";

      cin >> student[i].score[0] >> student[i].score[1] >> student[i].score[2];

      cout << "学生成绩录入成功!" << endl;

      return;

    }

  }

  cout << "未找到该学生信息!" << endl;

}

// 查询学生成绩

void queryScore() {

  int sno;

  cout << "请输入要查询成绩的学生学号:";

  cin >> sno;

  for (int i = 0; i < n; i++) {

    if (student[i].sno == sno) {

      cout << "学生姓名:" << student[i].name << endl;

      cout << "学生语文成绩:" << student[i].score[0] << endl;

      cout << "学生数学成绩:" << student[i].score[1] << endl;

      cout << "学生英语成绩:" << student[i].score[2] << endl;

      return;

    }

  }

  cout << "未找到该学生信息!" << endl;

}

// 修改学生成绩

void modifyScore() {

  int sno;

  cout << "请输入要修改成绩的学生学号:";

  cin >> sno;

  for (int i = 0; i < n; i++) {

    if (student[i].sno == sno) {

      cout << "请输入学生的新语文成绩、数学成绩和英语成绩:";

      cin >> student[i].score[0] >> student[i].score[1] >> student[i].score[2];

      cout << "学生成绩修改成功!" << endl;

      return;

    }

  }

  cout << "未找到该学生信息!" << endl;

}

最后,我们还需要实现成绩统计分析的功能。代码如下:


// 统计分析

void analyze() {

  double chineseTotal = 0, mathTotal = 0, englishTotal = 0;

  for (int i = 0; i < n; i++) {

    chineseTotal += student[i].score[0];

    mathTotal += student[i].score[1];

    englishTotal += student[i].score[2];

  }

  double chineseAverage = chineseTotal / n;

  double mathAverage = mathTotal / n;

  double englishAverage = englishTotal / n;

  cout << "语文平均分:" << chineseAverage << endl;

  cout << "数学平均分:" << mathAverage << endl;

  cout << "英语平均分:" << englishAverage << endl;

}

至此,我们已经完成了用C++编写学生成绩管理系统的全部功能。使用这个管理系统可以方便地帮助学校或教育机构更好地管理学生的成绩,评估学生的学业水平。

  
  

评论区

{{item['qq_nickname']}}
()
回复
回复