21xrx.com
2024-09-19 23:56:25 Thursday
登录
文章检索 我的文章 写文章
C++教务管理系统源代码
2023-07-10 20:30:43 深夜i     --     --
C++ 教务管理系统 源代码

教务管理系统是一个非常重要的系统,可以大大地提高学校教务工作的效率和质量。本文将介绍一个基于C++语言的教务管理系统的源代码。该系统具有以下功能:

1.学生信息管理

本系统可以实现对学生基本信息的添加、修改、删除和查询功能。学生的基本信息包括姓名、性别、学号、班级、身份证号、联系方式等。

2.教师信息管理

本系统可以实现对教师基本信息的添加、修改、删除和查询功能。教师的基本信息包括姓名、性别、教工号、任教科目、联系方式等。

3.课程信息管理

本系统可以实现对课程信息的添加、修改、删除和查询功能。课程信息包括课程名、课程编号、学分、学时等。

4.选课管理

本系统可以实现对学生选课情况的管理,并且可以显示选课人数。

5.成绩管理

本系统可以实现对学生的成绩管理功能,包括成绩的录入、修改、删除和查询功能。

以上是该教务管理系统的主要功能,下面给出该系统的源代码。

代码分为头文件、源文件和主文件三部分:

头文件部分:

#ifndef INFO_H

#define INFO_H

#include

#include

#include

using namespace std;

struct student

  string name;

  string sex;

  string number;

  string cls;

  string id;

  string phone;

;

struct teacher

  string name;

  string sex;

  string number;

  string subject;

  string phone;

;

struct course

  string name;

  string number;

  int credit;

  int hours;

;

extern student stu[100];

extern teacher tea[100];

extern course cour[100];

extern int stn;

extern int ten;

extern int con;

#endif

源文件部分:

#include "info.h"

student stu[100];

teacher tea[100];

course cour[100];

int stn = 0; // 学生个数

int ten = 0; // 教师个数

int con = 0; // 课程个数

int readall()

{

  ifstream infile;

  infile.open("data.txt");

  if (!infile)

    cout << "没有找到数据文件!" << endl;

    return 0;

  int n;

  // 读取学生信息

  infile >> n;

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

    infile >> stu[i].name >> stu[i].sex >> stu[i].number >> stu[i].cls >> stu[i].id >> stu[i].phone;

    stn++;

  }

  // 读取教师信息

  infile >> n;

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

    infile >> tea[i].name >> tea[i].sex >> tea[i].number >> tea[i].subject >> tea[i].phone;

    ten++;

  }

  // 读取课程信息

  infile >> n;

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

    infile >> cour[i].name >> cour[i].number >> cour[i].credit >> cour[i].hours;

    con++;

  }

  infile.close();

  return 1;

}

void saveall()

{

  ofstream outfile;

  outfile.open("data.txt");

  // 保存学生信息

  outfile << stn << endl;

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

    outfile << stu[i].name << " " << stu[i].sex << " " << stu[i].number << " " << stu[i].cls << " " << stu[i].id << " " << stu[i].phone << endl;

  }

  // 保存教师信息

  outfile << ten << endl;

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

    outfile << tea[i].name << " " << tea[i].sex << " " << tea[i].number << " " << tea[i].subject << " " << tea[i].phone << endl;

  }

  // 保存课程信息

  outfile << con << endl;

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

    outfile << cour[i].name << " " << cour[i].number << " " << cour[i].credit << " " << cour[i].hours << endl;

  }

  outfile.close();

}

主文件部分:

#include "menu.h"

#include "info.h"

int main()

{

  readall();//从文件读取数据

  while (1)

  {

    print_menu();// 显示菜单

    int c = select();// 选择操作

    if (c == 0) break;// 退出系统

    operation(c);// 执行操作

  }

  saveall();//将数据保存到文件

  return 0;

}

通过这个源代码,我们可以学习到如何使用C++语言来开发一个完整的教务管理系统。希望本文能够对大家有所帮助。

  
  

评论区

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