栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

学生管理系统C++

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

学生管理系统C++

 题目:学生管理系统设计

功能:学生管理系统设计,每个学生是一条记录,包括姓名、学号、性别、出生年月、专业、班级、家庭地址、宿舍号码等。系统要求实现以下功能:

1、输入功能:录入学生信息(包括学生学号、姓名、性别、出生年月、专业等);

2、显示功能:完成学生记录的显示。

3、查找功能:完成按学号或姓名查找学生的相关记录,并显示。
 

摘  要

学生成绩管理系统是典型的信息管理系统,是学校教务管理的重要组成部分,其处理信息量很大。

本课程设计是用C++实现对学生的成绩管理作一个简单的模拟,实质是建立学生成绩单链表,每条记录由学号、姓名与成绩组成,即链表中每个节点由4个数据域组成,,分别为:学号、姓名、成绩存放下一个节点地址的next。采用菜单选择操作方式完成6项功能分别写成6个函数,创建学生成绩对应建立学生单链表的现实、查询、修改于删除四大基本操作。该系统中的数据采用线性表中的链式存储结构即单链表来存储,用类型定义每个学生记录并采用外部文件方式记录数据,便于数据的读取和保存。

通过对学生成绩管理系统的制作,能够让使用者迅速地对学生的成绩做各项处理和显示,最终的到想要的信息,方便且易于操作。

关键词:学生成绩管理系统,C++,链表,文件

目 录

目录

摘  要... I

1.系统需求分析... 1

2.系统总体设计... 2

3.系统详细设计... 3

4.系统调试与运行... 4

5.系统分析(包含结果分析和改进措施)... 5

6.总结... 6

参考文献:... 7

[1]邓向荣.投资经济学.天津大学出版社.2001年... 7

……... 7

附录... 8

附录1. 8

1.系统需求分析

设计一个学生的类。类的设计测试数据的记录和将要实现的功能。学生成绩

管理系统有若干学生成绩记录组成,学生一条记录包括:学号、姓名、数学

成绩、物理成绩和英语成绩。主函数显示功能菜单,供用户选择操作。每步操

作之前,都要显示菜单。在主函数中调用类的方法。

2.系统总体设计

|1.输入学生成绩|

|2.查看学生成绩|

|3.删除学生成绩|

|4.修改学生成绩|

|5.学生成绩排序|

|6.读 取 文 件 |

|7.保 存 文 件 |

|0.  退   出   |

3.系统详细设计

主程序:

int main()

{

       int key;

       scoreList * abs = new scoreList;

       abs->index = 0;

      

      

       while (true)

       {

              showlist();

              cin >> key;

              switch (key)

              {

              case 0: return 0; break;

              case 1: inScore(abs); break;

              case 2: showScore(abs); break;

              case 3: deleteSore(abs); break;

              case 4: setScore(abs); break;

              case 5: sortScore(abs); break;

              case 6: fileOpen(abs); break;

              case 7: fileSave(abs); break;

              }

       }

       system("pause");

       return 0;

}

头文件:

// ConsoleApplication3.cpp : 定义控制台应用程序的入口点。

//#include"stdafx.h"

#include

#include

#include

#include

#include

#include

#define max 10000

using namespace std;

自定义菜单函数:

void showlist() {

       cout << "tttt --------------" << endl;

       cout << "tttt|1.输入学生成绩|" << endl;

       cout << "tttt|2.查看学生成绩|" << endl;

       cout << "tttt|3.删除学生成绩|" << endl;

       cout << "tttt|4.修改学生成绩|" << endl;

       cout << "tttt|5.学生成绩排序|" << endl;

       cout << "tttt|6.读 取 文 件 |" << endl;

       cout << "tttt|7.保 存 文 件 |" << endl;

       cout << "tttt|0.  退   出   |" << endl;

       cout << "tttt --------------" << endl;

}

定义总成绩数组:double sum[10000];

定义成绩结构体:

struct Score{

public:

       string id;

       string name;

       string sex;

       string yuScore;

       string shuScore;

       string waiScore;

       string sumScore;

};

定义成绩链表:

struct scoreList {

public:

       struct Score per[max];

       int index = 1;

};

写入文件函数:

inline string readFile(const string& filename) {

       ifstream in(filename);

       istreambuf_iterator begin(in), end;

       string content(begin, end);

       in.close();

       return content;

}

输入成绩函数:

void inScore(scoreList *abs) {

       if (abs->index == max) {

              cout << "成绩储存已满!" << endl;

       }

       else {

              string id;

              string name;

              string sex;

              string yuScore;

              string shuScore;

              string waiScore;

              string sumScore;

              cout << "学号:" << endl;

              cin >> id;

              cout << "姓名:" << endl;

              cin >> name;

              cout << "性别:1.男  2.女:" << endl;

              cin >> sex;

              cout << "语文成绩:" << endl;

              cin >> yuScore;

              cout << "数学成绩:" << endl;

              cin >> shuScore;

              cout << "外语成绩:" << endl;

              cin >> waiScore;

              abs->per[abs->index].id = id;

              abs->per[abs->index].name = name;

              abs->per[abs->index].sex = sex;

              abs->per[abs->index].yuScore = yuScore;

              abs->per[abs->index].shuScore = shuScore;

              abs->per[abs->index].waiScore = waiScore;

              sum[abs->index] = stof(abs->per[abs->index].yuScore) + stof(abs->per[abs->index].waiScore) + stof(abs->per[abs->index].waiScore);

              abs->index++;

             

              cout << "添加成功" << endl;

              system("pause");

              system("cls");

       }

}

输出成绩函数:

void showScore(scoreList *abs) {

       if (abs->index == 1) {

              cout << "成绩未录入!" << endl;

       }

       else {

              for (int i = 1; i < abs->index; i++) {

                     cout << "学号:" << abs->per[i].id << "t姓名:" << abs->per[i].name << "t性别:" << abs->per[i].sex << "t语文成绩:" << abs->per[i].yuScore << "t数学成绩:" << abs->per[i].shuScore << "t外语成绩:" << abs->per[i].waiScore << endl;

                     cout << "总成绩:" << sum[i] << endl;

              }

              system("pause");

              system("cls");

       }

}

删除函数:

int isExist(scoreList *abs, string name)

{

       for (int i = 1; i < abs->index; i++)

       {

              if (abs->per[i].name == name)

              {

                     return i;

              }

       }

       return -1;

}

删除成绩函数:

void deleteSore(scoreList *abs) {

       cout << "请输入你要删除的姓名:" << endl;

       string name;

       cin >> name;

       int i = isExist(abs, name);

       if (i != -1)

       {

              cout << "你要删除的人员信息是:" << endl;

              cout << "学号:" << abs->per[i].id << "t姓名:" << abs->per[i].name << "t性别:" << (abs->per[i].sex == "1" ? "男" : "女") << "t语文成绩:" << abs->per[i].yuScore << "t数学成绩:" << abs->per[i].shuScore << "t外语成绩:" << abs->per[i].waiScore << endl;

              cout << "确认是否删除:1:是    2:否" << endl;

              int k;

              cin >> k;

              if (k == 1)

              {

                     for (int j = i; j < abs->index; j++)

                            abs->per[j] = abs->per[j + 1];

                     abs->index--;

                     cout << "已删除" << endl;

              }

              else  cout << "取消删除" << endl;

              system("pause");

              system("cls");

       }

       else  cout << "没找到此人" << endl;

       system("pause");

       system("cls");

}

修改成绩函数:

void setScore(scoreList *abs) {

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

       string id;

       cin >> id;

       int i = isExist(abs, id);

       if (i != -1)

       {

              cout << "你要修改的人员原信息是:" << endl;

              cout << "学号:" << abs->per[i].id << "t姓名:" << abs->per[i].name << "t性别:" << (abs->per[i].sex == "1" ? "男" : "女") << "t语文成绩:" << abs->per[i].yuScore << "t数学成绩:" << abs->per[i].shuScore << "t外语成绩:" << abs->per[i].waiScore << endl;

              cout << "确认是否修改:1:是    2:否" << endl;

              int k;

              cin >> k;

              if (k == 1)

              {

                     string id;

                     string name;

                     string sex;

                     string yuScore;

                     string shuScore;

                     string waiScore;

                     cout << "学号:" << endl;

                     cin >> id;

                     cout << "姓名:" << endl;

                     cin >> name;

                     cout << "性别:1.男  2.女:" << endl;

                     cin >> sex;

                     cout << "语文成绩:" << endl;

                     cin >> yuScore;

                     cout << "数学成绩:" << endl;

                     cin >> shuScore;

                     cout << "外语成绩:" << endl;

                     cin >> waiScore;

                     abs->per[abs->index].id = id;

                     abs->per[abs->index].name = name;

                     abs->per[abs->index].sex = sex;

                     abs->per[abs->index].yuScore = yuScore;

                     abs->per[abs->index].shuScore = shuScore;

                     abs->per[abs->index].waiScore = waiScore;

                     abs->index++;

                    

                     cout << "添加成功" << endl;

                     system("pause");

                     system("cls");

              }

              else  cout << "取消修改!" << endl;

       }

       system("pause");

       system("cls");

}

成绩排序函数:

void sortScore(scoreList *abs) {

       for (int i = 1; i < abs->index; i++) {

              for (int j = 1; jindex-i; j++) {

                     if (sum[j]

                            string temp;

                            double t;

                            t = sum[j];

                            sum[j] = sum[j + 1];

                            sum[j + 1] = t;

                            temp = abs->per[j].id;

                            abs->per[j].id = abs->per[j + 1].id;

                            abs->per[j + 1].id = temp;

                            temp = abs->per[j].name;

                            abs->per[j].name = abs->per[j + 1].name;

                            abs->per[j + 1].name = temp;

                            temp = abs->per[j].sex;

                            abs->per[j].sex = abs->per[j + 1].sex;

                            abs->per[j + 1].sex = temp;

                            temp = abs->per[j].yuScore;

                            abs->per[j].yuScore = abs->per[j + 1].yuScore;

                            abs->per[j + 1].yuScore = temp;

                            temp = abs->per[j].shuScore;

                            abs->per[j].shuScore = abs->per[j + 1].shuScore;

                            abs->per[j + 1].shuScore = temp;

                            temp = abs->per[j].waiScore;

                            abs->per[j].waiScore = abs->per[j + 1].waiScore;

                            abs->per[j + 1].waiScore = temp;

                            //for (int i = 0; i < abs->index; i++) {

                            //cout << "学号:" << abs->per[i].id << "t姓名:" << abs->per[i].name << "t性别:" << abs->per[i].sex << "t语文成绩:" << abs->per[i].yuScore << "t数学成绩:" << abs->per[i].shuScore << "t外语成绩:" << abs->per[i].waiScore << endl;

                            //cout << "总成绩:" << sum[i] << endl;

                            //}

                     }

              }

              cout << "学号:" << abs->per[i].id << "t姓名:" << abs->per[i].name << "t性别:" << abs->per[i].sex << "t语文成绩:" << abs->per[i].yuScore << "t数学成绩:" << abs->per[i].shuScore << "t外语成绩:" << abs->per[i].waiScore << endl;

              cout << "总成绩:" << sum[i] << endl;

       }

       system("pause");

       system("cls");

}

打开成绩文件:

void fileOpen(scoreList *abs) {

       system("cls");

       cout << "文件读取中" << endl;

       ifstream ifs;

       abs->index = 0;

       ifs.open("test.txt", ios::in);

       if (!ifs.is_open() || ifs.eof())

       {

              cout << "文件打开失败" << endl;

              return;

       }

       else {

              string buf1;

              string buf2;

              string buf3;

              string buf4;

              string buf5;

              string buf6;

              while (ifs >> buf1 && ifs >> buf2 && ifs >> buf3 && ifs >> buf4 && ifs >> buf5&& ifs >> buf6)

              {

                     cout << buf1 << endl;

                     cout << buf2 << endl;

                     cout << buf3 << endl;

                     cout << buf4 << endl;

                     cout << buf5 << endl;

                     cout << buf6 << endl;

                     abs->per[abs->index].id = buf1;

                     abs->per[abs->index].name = buf2;

                     abs->per[abs->index].sex = (buf3 == "男" ? "1" : "2");

                     abs->per[abs->index].yuScore = buf4;

                     abs->per[abs->index].shuScore = buf5;

                     abs->per[abs->index].waiScore = buf6;

                     abs->index++;

              }

              cout << "文件读取成功" << endl;

       }

       ifs.close();

}

保存学习成绩文件函数:

void fileSave(scoreList *abs) {

       ofstream ofs;

       ofs.open("test.txt", ios::out);

       cout << "文件保存中....." << endl;

       for (int i = 0; i < abs->index; i++)

       {

              ofs << abs->per[i].id << endl

                     << abs->per[i].name << endl

                     << (abs->per[i].sex == "1" ? "男" : "女") << endl

                     << abs->per[i].yuScore << endl

                     << abs->per[i].shuScore << endl

                     << abs->per[i].waiScore << endl;

       }

       //  ofs << EOF;

       ofs.close();

       cout << "保存成功!" << endl;

       system("pause");

       system("cls");

}

4.系统调试与运行

5.系统分析(包含结果分析和改进措施) 5.1结果分析

该学生成绩管理系统能够完成一些基本的操作功能,例如查询,删除,修改等功能,运用了面向对象的程序设计,所以程序比较安全可靠,功能也比较齐全,操作方便,界面清晰,容易维护和扩充。但是该系统还是有一些不足。

对于系统的查询这一模块设计的比较简单,仅仅只需要全部成绩的平均成绩进入系统还是想的有点不全面,应考虑各科成绩。

对于修改的这块方面,因为是通过学号或者姓名进行修改的,姓名有可能会重复,导致删除的信息不是用户想要的效果。系统也没有进行提示,只有学号才是唯一的,且删除时姓名重复系统不会提醒。

5.2改进措施

对于删除这项操作如果用姓名进行查找,如果有姓名重复的,系统应该提醒下,并输出学号来进行准确删除,以免造成删除了用户本不想删除的信息。

对于排序这项操作应该设置不同科目的单项排序,最后来一个总成绩的排序。以此可以满足用户需要单项成绩的排名。

对于修改这项操作如果用姓名进行查找,如果有姓名重复的,系统应该提醒下,并输出学号来进行准确修改,以免造成修改了用户本不想修改的信息。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/983164.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号