学生成绩管理系统

用**++单链表数据结构完成c++的学生成绩管理系统++**,此系统的具体功能如下:

本人小萌新一个,遇到BUG是正常现象。并且类与对象写的不太理想。@-@

写了一个Database存放所有数据,但这肯定浪费资源,你们看着改改吧。

cpp 复制代码
`class DataBase
{
public:
    virtual void run();//多态
    void setID(int ID);
    void setName(string Name);
    void setSex(string Sex);
    void setChinese(double Chinese);
    void setMath(double Math);
    void setEnglish(double English);
    void setAverage(double Average);
    void setSum(double Sum);
    void setNews(string news);
    void setSolute(string solute);
    void setAccount(string A);
    void setPassword(string P);
    void setWordprotect(string W);
    void setNext(DataBase* next);
    int& getID();
    string& getName();
    string& getSex();
    double& getChinese();
    double& getMath();
    double& getEnglish();
    double& getAverage();
    double& getSum();
    string& getNews();
    string& getSolute();
    string& getAccount();
    string& getPassword();
    string& getWordprotect();
    DataBase* getNext();
private:
    int ID = 0;            //学号
    string Name = "";    //姓名    
    string Sex = "";    //性别
    double Chinese = 0;    //语文
    double Math = 0;    //数学
    double English = 0; //英语
    double Average = 0;    //平均分
    double Sum = 0;        //总分
    string News = "";    //信息反馈
    string Solute = "";     //解决方案
    string account = "";    //账号
    string password = "";    //密码
    string wordprotect = "";//密保
    DataBase* next = nullptr;//指针域
};`
  1. 登录系统功能。
  1. 动画效果进入主界面,可选择教师端或学生端。
cpp 复制代码
`void menu()
{
    cout << "\t\t*********************************************" << endl;
    cout << "\t\t*****\t\t 1.教师端\t\t*****" << endl;
    cout << "\t\t*****\t\t 2.学生端\t\t*****" << endl;
    cout << "\t\t*****\t\t 0.退出  \t\t*****" << endl;
    cout << "\t\t*********************************************" << endl;
}

void Homepage()
{
    WelcomeScreen();
    while (1)
    {
        system("cls");
        menu();
        cout << "\t\t选择:";
        DataBase* F = NULL;//多态进入不同界面操作
        //这里也可以传对象实现多态
        string acc;
        cin >> acc;
        if (acc == "1") {
            F = new Teacher();
            F->run();//老师界面
        }
        else if (acc == "2") {
            F = new Student();
            F->run();//学生界面
        }
        else if (acc == "0") {
            F = new DataBase();
            F->run();//退出
            break;
        }
        else {
            continue;
        }
    }
}

int main()
{
    Homepage();
    return 0;
}`
  1. 教师端:可以登录账号、注册账号、注销账号、找回注销的账号、修改密码以及退出。
cpp 复制代码
`void menu1()
{
    cout << "\t\t\t\t 教师端用户" << endl;
    cout << "\t\t*********************************************" << endl;
    cout << "\t\t*****\t\t 1.登录平台\t\t*****" << endl;
    cout << "\t\t*****\t\t 2.注册账号\t\t*****" << endl;
    cout << "\t\t*****\t\t 3.找回账号\t\t*****" << endl;
    cout << "\t\t*****\t\t 0.退出    \t\t*****" << endl;
    cout << "\t\t*********************************************" << endl;
}

void Teacher::run()
{
    while (1)
    {
        system("cls");
        menu1();
        cout << "\t\t请选择:";
        string ffll = " ";
        cin >> ffll;
        if (ffll == "1") {
            cout << "\t\t***教师  登录***" << endl;
            login();
        }
        else if (ffll == "2") {
            cout << "\t\t***注册  账号***" << endl;
            regist();
        }
        else if (ffll == "3") {
            cout << "\t\t***找回  账号***" << endl;
            find();
        }
        else if (ffll == "0") {
            break;
        }
        else {
            continue;
        }
    }
}

void Teacher::login()
{
    int pan = 1;//输入次数
    while (1) {
        system("cls");
        string ac = " ";
        char pa[10];
        char s;
        int j = 0;//确保数组从0开始 
        while (1)
        {
            cout << "\t\t请输入账号(0退出):";
            cin >> ac;
            DataBase* ac1 = head1->getNext();
            while (ac1 != NULL)
            {
                if (ac == ac1->getAccount())break;
                ac1 = ac1->getNext();
            }
            if (ac1 == NULL) {
                cout << "\t\t未查寻到此账号!" << endl;
            }
            else {
                break;
            }
            if (ac == "0")break;
        }
        if (ac == "0")break;
        cout << "\t\t请输入密码:";
        while ((s = _getch()) != '\r')
        {
            if (s == '\b')
            {
                if (j > 0) {
                    j--;//回删一位 
                    cout << "\b \b";
                }
            }
            else if (j < 8)
            {   //控制密码位数 
                pa[j] = s;  //存入数组 
                j++;
                putchar('*'); //用* 代替密码 
            }
        }
        pa[j] = '\0';//避免乱码
        int ccvv = 0;
        DataBase* pp = head1->getNext();
        while (pp != NULL)
        {
            if ((pp->getAccount() == ac) && (pp->getPassword() == pa))
            {
                ccvv = 1;
                cout << endl << "\t\t验证正确" << endl;
                cout << endl;
                cout << "\t\t";
                for (int i = 0; i < 20; i++)
                {
                    cout << ".";
                    Sleep(50);
                }
                storage = pp->getAccount();//存一下账号
                operat();//进入教师界面
                break;
            }
            pp = pp->getNext();//遍历    
        }
        if (pp == NULL)
        {
            cout << endl << "\t\t第" << pan++ << "次密码错误!" << endl;
            system("pause");
        }
        if (pan == 4) {
            cout << endl << "\t\t已输入3次,退出登录" << endl;
            system("pause");
            break;
        }
        if (ccvv == 1)break;
    }
}

void Teacher::regist()
{
    while (1)
    {
        system("cls");
        DataBase* p = new DataBase();
        string account = " ", password = " ", wordprotect = "";
        cout << endl;
        cout << "\t\t*注册账号(0退出):";
        DataBase* p1 = head1->getNext();//查重
        cin >> account;
        if (account == "0")break;
        while (p1 != NULL)
        {
            if (p1->getAccount() == account)
            {
                cout << endl;
                cout << "\t\t此账号已存在!" << endl;
                system("pause");
                break;
            }
            p1 = p1->getNext();
        }
        if (p1 != NULL)continue;
        p->setAccount(account);
        while (1)
        {
            cout << "\t\t*设置密码(0退出):";
            cin >> password;
            if (password == "0")break;
            if (password.length() > 8) {
                cout << "\t\t密码超出八位!请再次设置" << endl;//确保密码只能设置8位
                continue;
            }
            break;
        }
        p->setPassword(password);
        cout << "\t\t*设置密保(0退出):";
        cin >> wordprotect;
        if (wordprotect == "0")break;
        p->setWordprotect(wordprotect);
        //头插
        p->setNext(head1->getNext());
        head1->setNext(p);
        write("E://1C//学生管理//rtea.txt", head1);
        cout << "\t\t*注册完成*" << endl;
        p = p->getNext();
        system("pause");
        break;
    }
}

int cratical = 0;//判断密码修改是否成功

void Teacher::logout()
{
    system("cls");
    string a = "", b = "";
    DataBase* s;  //遍历注销账户
    DataBase* q;
    while (1)
    {
        cratical = 0;
        s = head1->getNext();  
        q = head1;
        cout << "\t\t你的的账号:" << storage << endl;
        while (s != NULL)
        {
            if (s->getAccount() == storage)
            {
                break;
            }
            q = s;
            s = s->getNext();
        }
        if (s != NULL)break;
    }
    int ding = 1;
    while (1)
    {
        cratical = 0;
        cout << "\t 第 " << ding << " 次输入" << endl;
        ding++;
        cout << "\t\t请输入要注销账号的密码(0 退出):";
        cin >> a;
        if (a == "0")break;
        cout << endl;
        cout << "\t\t请输入要注销账号的密保(0 退出):";
        cin >> b;
        if (b == "0")break;
        cout << endl;
        int in1 = 1, in2 = 9;
        if (s->getPassword() == a)
        {
            in1 = 2;//密码
        }
        if (s->getWordprotect() == b)
        {
            in2 = 3;//密保
        }
        if (in1 + in2 == 5)
        {
            q->setNext(s->getNext());
            delete s;
            s = NULL;
            cout << endl << "\t\t删除成功!" << endl;
            write("E://1C//学生管理//rtea.txt", head1);
            cratical = 22;
            system("pause");
        }
        int in = 0;
        in = in1 + in2;
        if (in == 10)
        {
            cout << "\t\t密码和密保输入错误!" << endl;
            system("pause");
        }
        else if (in == 11)
        {
            cout << "\t\t密保输入错误!" << endl;
            system("pause");
        }
        else if (in == 4)
        {
            cout << "\t\t密码输入错误!" << endl;
            system("pause");
        }
        if (in == 5)
        {
            DataBase* c = new DataBase();//开辟空间 用于存注销的账号
            c->setAccount(storage);
            c->setPassword("0");//密码再行设置
            c->setWordprotect(b);
            c->setNext(headmode->getNext());
            headmode->setNext(c);
            write("E://1C//学生管理//rteafind.txt", headmode);
            c = c->getNext();
            break;
        }
        if (ding == 4) {
            cout << "\t\t已输入3次错误输入!强制退出" << endl;
            system("pause");
            break;
        }
    }
}

void Teacher::find()
{
    while (1)
    {
        system("cls");
        cout << endl;
        cout << "\t\t请输入要找回的账号(0退出):";
        string a1 = " ";
        cin >> a1;
        if (a1 == "0")break;
        DataBase* f1 = headmode->getNext();
        DataBase* f2 = headmode;
        int o = 1;
        while (f1 != NULL)
        {
            if (a1 == f1->getAccount())
            {
                for (int i = 1; i < 5; i++)
                {
                    if (i == 4)
                    {
                        cout << "\t输入3次全部错误退出验证!" << endl;
                        o = 3;
                        system("pause");
                        break;
                    }
                    cout << "\t第 " << i << " 次输入" << endl;
                    cout << "\t请输入密保:";
                    string a2;
                    cin >> a2;
                    if (a2 == f1->getWordprotect()) {
                        cout << "\t密保确认成功!" << endl;
                        cout << "\t已找回账号" << endl;
                        //找回密码 写入rtea文件
                        DataBase* p11 = new DataBase();
                        p11->setAccount(a1);
                        cout << "\t重新设置密码:";
                        string ma = " ";
                        cin >> ma;
                        p11->setPassword(ma);
                        cout << "\t重新设置密保:";
                        string pr = " ";
                        cin >> pr;
                        p11->setWordprotect(pr);
                        p11->setNext(head1->getNext());
                        head1->setNext(p11);
                        write("E://1C//学生管理//rtea.txt", head1);
                        o = 3;
                        system("pause");
                        break;
                    }
                    else {
                        cout << "\t输入错误!" << endl;
                    }
                }
            }
            if (o == 3)
            {
                //删除rteafind 中的账号信息
                f2->setNext(f1->getNext());
                delete f1;
                f1 = NULL;
                write("E://1C//学生管理//rteafind.txt", headmode);
                break;
            }
            f2 = f1;
            f1 = f1->getNext();
        }
        if (o == 3)break;
        if (f1 == NULL)
        {
            cout << "\t 查询无此账号!" << endl;
            system("pause");
        }
    }
}

void Teacher::modify()
{
    int chi = 0;
    while (1)
    {
        cratical = 0;
        system("cls");
        cout << endl;
        cout << "\t\t你的账号:" << storage << endl;
        cout  << "请输入密保方可修改密码:";
        string mi;
        cin >> mi;
        DataBase* move = head1->getNext();
        while (move != NULL)
        {
            if (move->getWordprotect() == mi && move->getAccount() == storage)
            {
                cout << "\t\t原密码:" << move->getPassword() << endl;
                string llop;
                cout << "\t\t新密码:";
                cin >> llop;
                move->setPassword(llop);
                write("E://1C//学生管理//rtea.txt", head1);
                cratical = 21;
                cout << endl << "\t\t修改完成!";
                system("pause");
                break;
            }
            move = move->getNext();
        }
        if (move == NULL)
        {
            cout << endl << "\t第" << ++chi << "次密保输入错误!" << endl;
            system("pause");
        }
        else {
            break;
        }
        if (chi == 3)
        {
            cout << "\t\t三次输入全部错误!马上退出" << endl;
            system("pause");
            break;
        }
    }
}`
  1. 学生端:可以登录账号、注册账号、注销账号、修改密码以及退出。与教师端大同小异。
  1. 教师端功能
cpp 复制代码
`#pragma once
#include"DataBase.h"
class Teacher : public DataBase
{
private: //学生不可继承的功能
    bool Turnitin(int ID);//查重
    void CreateDataBase();    //添加学生
    void Sort();        //按成绩排序
    void M1odify();        //修改学生信息
    void Delete();        //删除学生信息
public:
    Teacher();// head节点
    ~Teacher();
    virtual void run();
    void login();    //账号登录
    void regist();    //账号注册
    void logout();    //账号注销
    void find();    //账号找回
    void modify();    //修改密码
    void read(const char* file, DataBase* head);
    void write(const char* file, DataBase* head);
    void operat();        //运转器
    void Search();        //查找学生信息
    void Show();        //显示全部学生信息
    void Back();        //学生信息反馈    
    void Readfile(const char* Filename);//读文件
    void Writefile(const char* Filename);//写文件
};`
  1. 添加学生信息:可录入学号、姓名、性别、语文、数学、英语等相关信息和成绩,并且由算法实现平均分、总分存入链表写入文件等的操作。
cpp 复制代码
`bool Teacher::Turnitin(int ID)// 学号查重
{
    DataBase* h = head->getNext();
    while (h != NULL)
    {
        if (h->getID() == ID)
        {
            cout << "学号 " << ID << " 重复" << endl;
            cout << "请输入新的学号:";
            return false;
        }
        h = h->getNext();
    }
    return true;
}

void Teacher::CreateDataBase() //添加新的学生信息
{
    system("cls");
    DataBase* p = head->getNext();
    cout << "\t添加学生数量:";
    int n = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        p = new DataBase();
        cout << "请输入第" << i + 1 << "位:" << endl;
        int ID = 0;
        string Name = " ", Sex = " ";
        double Chinese = 0, Math = 0, English = 0, Average = 0, Sum = 0;
        cout << " 学号:";
        cin >> ID;
        while (1)
        {
            if (!Turnitin(ID))
            {
                cin >> ID;
            }
            else {
                break;
            }
        }
        p->setID(ID);
        cout << " 姓名:";
        cin >> Name;
        p->setName(Name);
        cout << " 性别:";
        while (1)
        {
            cin >> Sex;
            if (Sex == "男" || Sex == "女")
            {
                break;
            }
            else
            {
                cout << "只能输入男/女\t请再次输入:";
            }
        }
        p->setSex(Sex);
        cout << " 语文:";
        cin >> Chinese;
        p->setChinese(Chinese);
        cout << " 数学:";
        cin >> Math;
        p->setMath(Math);
        cout << " 英语:";
        cin >> English;
        p->setEnglish(English);
        p->getSum() = Chinese + Math + English;
        p->getAverage() = p->getSum() / 3.0;
        //newDataBase->next = temp->next;//头插法
        //反馈信息
        p->setNews("无");//无反馈信息
        p->setSolute("无");//无解决方案
        p->setNext(head->getNext());
        head->setNext(p);
        Writefile("E://1C//学生管理//1.txt");
        cout << "添加完成!" << endl;
        p = p->getNext();
    }
    system("pause");
    system("cls");
}`
  1. 显示学生信息:可显示全部学生信息,并且每10个人会翻一下页及统计总人数。
cpp 复制代码
`void Teacher::Show()//显示全部信息
{
    system("cls");
    cout << "学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
    DataBase* o = head->getNext(); //遍历得到总人数
    DataBase* h = head->getNext(); //遍历显示每个人的所有信息
    int sd = 0, ss = 1;
    while (o != NULL)
    {
        sd = sd + 1;
        o = o->getNext();
    }
    int i = 1;
    while (h != NULL)
    {
        if (ss > 0 && ss < 11)
        {
            ss = ss + 1;
            h->getSum() = h->getChinese() + h->getEnglish() + h->getMath();
            h->getAverage() = h->getSum() / 3.0;
            cout << h->getID() << "\t" << h->getName() << "\t" << h->getSex() << "\t";
            cout << fixed << setprecision(2) << h->getChinese() << "\t" << h->getMath() << "\t" << h->getEnglish() << "\t" << h->getAverage() << "\t" << h->getSum() << endl;
        }
        else {
            ss = 1;
            cout << "\t第[" << i++ << "/10人]页" << endl;
            system("pause");
            system("cls");
            cout << "学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
            continue;
        }
        h = h->getNext();
    }
    cout << "第[" << i++ << "/10人]页" << endl;
    cout << "参加考试共有【" << sd << "】个学生" << endl;
    system("pause");
}`
  1. 修改学生信息:修改操作。
cpp 复制代码
`void Teacher::M1odify()//修改
{
    while (1)
    {
        system("cls");
        DataBase* p1 = head->getNext();//按学号修改
        DataBase* p2 = head->getNext();//修改学号
        cout << "\t\t1、请输入学号:" << endl;
        cout << "\t\t2、修改学号" << endl;
        cout << "\t\t0、退出" << endl;
        cout << "\t选择:";
        int ch;
        cin >> ch;
        if (ch==1) //判断学号
        {
            int ID1 = 0;
            cout << "请输入你的学号";
            cin >> ID1;
            int q1 = 1;
            while (p1 != NULL)//遍历
            {    
                if (p1->getID() == ID1)
                {
                    q1 = 0;
                    cout << "学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
                    cout << p1->getID() << "\t" << p1->getName() << "\t" << p1->getSex() << "\t";
                    cout << fixed << setprecision(2) << p1->getChinese() << "\t" << p1->getMath() << "\t" << p1->getEnglish() << "\t" << p1->getAverage() << "\t" << p1->getSum() << endl;
                    while (1) { //多次修改
                        cout << "(可修改姓名、性别、语文、数学、英语 按0可取消修改)" << endl;
                        char ccc[100];
                        cout << "选择:";
                        cin >> ccc;
                        if (!strcmp(ccc, "姓名"))
                        {
                            cout << "修改为:";
                            string name;
                            cin >> name;
                            p1->getName() = name;
                            cout << "\t姓名修改成功!" << endl;
                        }
                        else if (!strcmp(ccc, "性别"))
                        {
                            cout << "修改为:";
                            string sex;
                            while (1)
                            {
                                cin >> sex;
                                if (sex == "男" || sex == "女")
                                {
                                    break;
                                }
                                else
                                {
                                    cout << "只能输入男/女\t请再次输入:";
                                }
                            }
                            p1->getSex() = sex;
                            cout << "\t性别修改成功!" << endl;
                        }
                        else if (!strcmp(ccc, "语文"))
                        {
                            cout << "修改为:";
                            double chin = 0;
                            cin >> chin;
                            p1->getChinese() = chin;
                            p1->getSum() = chin + p1->getMath() + p1->getEnglish();
                            p1->getAverage() = p1->getSum() / 3.0;
                            cout << "\t语文成绩修改成功!" << endl;
                        }
                        else if (!strcmp(ccc, "数学"))
                        {
                            cout << "修改为:";
                            double ma = 0;
                            cin >> ma;
                            p1->getMath() = ma;
                            p1->getSum() = ma + p1->getChinese() + p1->getEnglish();
                            p1->getAverage() = p1->getSum() / 3.0;
                            cout << "\t数学成绩修改成功!" << endl;
                        }
                        else if (!strcmp(ccc, "英语"))
                        {
                            cout << "修改为:";
                            double eng = 0;
                            cin >> eng;
                            p1->getEnglish() = eng;
                            p1->getSum() = eng + p1->getMath() + p1->getChinese();
                            p1->getAverage() = p1->getSum() / 3.0;
                            cout << "\t英语成绩修改成功!" << endl;
                        }
                        else if (!strcmp(ccc, "0"))
                        {
                            break;
                        }
                    }
                }
                p1 = p1->getNext();
            }
            if(q1==1)
                {
                    cout << "\t\t无此学号的学生!" << endl;
                    system("pause");
                }
            Writefile("E://1C//学生管理//1.txt");
        }
        else if (ch==2)
        {
            cout << "选择要修改的学号:";
            int xu, xv = 0;//学号 
            cin >> xu;
            while (p2 != NULL)
            {
                if (p2->getID() == xu)
                {
                    cout << "修改为:";
                    int changexu;
                    cin >> changexu;
                    DataBase* q1 = head->getNext();
                    int y = 0;
                    while (q1 != NULL)
                    {
                        if (q1->getID() == changexu)
                        {
                            y = 1;
                            cout << "已有此学号的信息,不可修改!" << endl;
                            break;
                        }
                        q1 = q1->getNext();
                    }
                    if (y == 1)break;
                    p2->getID() = changexu;
                    cout << "\t修改成功!" << endl;
                    Writefile("E://1C//学生管理//1.txt");
                    cout << "学号已经修改为" << p2->getID() << " 请妥善保管" << endl;
                    break;
                }
                p2 = p2->getNext();
            }
            if (p2 == NULL)
            {
                cout << "没有此学号" << endl;
            }
            system("pause");
        }
        else if (ch==0)
        {
            break;
        }
    }
}`
  1. 查找学生信息:对学生查找。
cpp 复制代码
`void Teacher::Search()
{
    while (1)
    {
        DataBase* pM = head->getNext(); //按姓名
        DataBase* pN = head->getNext();    //按学号
        system("cls");
        cout << "\t\t1、按学号查找:" << endl;
        cout << "\t\t2、按姓名查找:" << endl;
        cout << "\t\t0、退出:" << endl;
        cout << "\t选择:";
        char choice[100] = { 0 };
        gets_s(choice);
        if (!strcmp(choice, "2"))
        {
            cout << "请输入你的姓名:" << endl;
            string Name;
            cin >> Name;
            int cc = 0;
            cout << "序号\t学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
            while (pM != NULL)
            {
                if (pM->getName() == Name)
                {
                    cc++;
                    cout << cc << "\t" << pM->getID() << "\t" << pM->getName() << "\t" << pM->getSex() << "\t";
                    cout << fixed << setprecision(2) << pM->getChinese() << "\t" << pM->getMath() << "\t" << pM->getEnglish() << "\t" << pM->getAverage() << "\t" << pM->getSum() << endl;
                }
                pM = pM->getNext();
            }
            cout << "已查到以上[" << cc << "]个学生" << endl;
            system("pause");
        }
        else if (!strcmp(choice, "1"))
        {
            cout << "请输入你的学号:" << endl;
            int ID;
            cin >> ID;
            int cc = 0;
            while (pN != NULL)
            {
                if (pN->getID() == ID)
                {
                    cc++;
                    cout << "序号\t学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
                    cout << cc << "\t" << pN->getID() << "\t" << pN->getName() << "\t" << pN->getSex() << "\t";
                    cout << fixed << setprecision(2) << pN->getChinese() << "\t" << pN->getMath() << "\t" << pN->getEnglish() << "\t" << pN->getAverage() << "\t" << pN->getSum() << endl;
                    break;
                }
                pN = pN->getNext();
            }
            if (pN == NULL)
            {
                cout << "没有学号为 " << ID << " 的学生" << endl;
            }
            system("pause");
        }
        else if (!strcmp(choice, "0"))
        {
            break;
        }
    }
}`
  1. 删除学生信息:删除学生各个数据。
cpp 复制代码
`void Teacher::Delete()
{
    while (1)
    {
        system("cls");
        DataBase* p = head->getNext();
        DataBase* q = head->getNext();
        DataBase* pq = head;
        int ji = 0;
        cout << "学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
        while (p != NULL)
        {
            ji++;
            cout << p->getID() << "\t" << p->getName() << "\t" << p->getSex() << "\t";
            cout << fixed << setprecision(2) << p->getChinese() << "\t" << p->getMath() << "\t" << p->getEnglish() << "\t" << p->getAverage() << "\t" << p->getSum() << endl;
            p = p->getNext();
        }
        cout << "\t\t共计【" << ji << "】名学生" << endl;
        cout << "\t\t输入学号便可删除( 0 退出):";
        int dd = 0, pan = 1;
        cin >> dd;
        while (q != NULL)
        {
            if (dd == 0)
            {
                cout << "\t\t退出成功!" << endl;
                break;
            }
            if (q->getID() == dd)
            {
                pq->setNext(q->getNext());
                delete q;
                q = NULL;
                cout << "\t\t删除成功!" << endl;
                Writefile("E://1C//学生管理//1.txt");
                pan = 0;
                break;
            }
            pq = q;
            q = q->getNext();
        }
        if (dd == 0)break;
        if (pan == 1)
        {
            cout << "\t\t未查询到此学号!" << endl;
        }
        system("pause");
    }
}`
  1. 排序操作:可对语文、数学、英语等成绩单独操作,也可对平均分、总分排序。
cpp 复制代码
`void sortMachine(int i)  //排序机,若只有一个人无法排序
{

    DataBase* p, * q, * temp;
    temp = head;
    p = temp->getNext()->getNext();
    temp->getNext()->setNext(NULL);
    q = p->getNext();
    while (1)
    {
        if (head->getNext() == NULL)break;
        if (i == 1)//语文
        {
            while (temp->getNext() != NULL && temp->getNext()->getChinese() > p->getChinese())
                temp = temp->getNext();//如果满足条件后移
        }
        else if (i == 2)//数学
        {
            while (temp->getNext() != NULL && temp->getNext()->getMath() > p->getMath())
                temp = temp->getNext();
        }
        else if (i == 3)//英语
        {
            while (temp->getNext() != NULL && temp->getNext()->getEnglish() > p->getEnglish())
                temp = temp->getNext();
        }
        else if (i == 4)//平均分
        {
            while (temp->getNext() != NULL && temp->getNext()->getAverage() > p->getAverage())
                temp = temp->getNext();
        }
        else if (i == 5)//总分
        {
            while (temp->getNext() != NULL && temp->getNext()->getSum() > p->getSum())
                temp = temp->getNext();
        }
        p->setNext(temp->getNext());
        temp->setNext(p);//temp一直指向p的下一个
        temp = head;//从头遍历
        p = q;//p后移一个
        if (q == NULL)break;
        q = q->getNext();
    }
    DataBase* o = head->getNext();
    int c = 0;
    cout << "名次\t学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
    while (o != NULL)
    {
        c++;
        cout << c << "\t" << o->getID() << "\t" << o->getName() << "\t" << o->getSex() << "\t";
        cout << fixed << setprecision(2) << o->getChinese() << "\t" << o->getMath() << "\t" << o->getEnglish() << "\t" << o->getAverage() << "\t" << o->getSum() << endl;
        o = o->getNext();
    }
    system("pause");
}

void Teacher::Sort() //按成绩排序
{
    while (1)
    {
        system("cls");
        DataBase* s1 = head->getNext();
        DataBase* s2 = head;
        cout << "\t\t1、按语文排序" << endl;
        cout << "\t\t2、按数学排序" << endl;
        cout << "\t\t3、按英语排序" << endl;
        cout << "\t\t4、按平均分排序" << endl;
        cout << "\t\t5、按总成绩排序" << endl;
        cout << "\t\t0、退出" << endl;
        cout << "\t\t选择:";
        int chose = 0;
        cin >> chose;
        if (chose == 1)
        {
            sortMachine(chose);
        }
        else if (chose == 2)
        {
            sortMachine(chose);
        }
        else if (chose == 3)
        {
            sortMachine(chose);
        }
        else if (chose == 4)
        {
            sortMachine(chose);
        }
        else if (chose == 5)
        {
            sortMachine(chose);
        }
        else if (chose == 0)
        {
            break;
        }
    }
}`
  1. 学生信息反馈:学生端可发出信息教师端接收,并且可阅览反馈的问题,教师端可写下解决办法,传入学生端。
cpp 复制代码
`void Teacher::Back()
{
    while (1)
    {
        system("cls");
        DataBase* s9 = head->getNext();
        DataBase* s6 = head->getNext();
        int ssp = 0;
        cout << "序号\t学号\t姓名\t性别\t反馈信息\t解决方案" << endl;
        while (s9 != NULL)
        {
            if (s9->getNews() != "无")
            {
                cout << ++ssp << "\t" << s9->getID() << "\t" << s9->getName() << "\t" << s9->getSex() << "\t" << s9->getNews() << "\t\t" << s9->getSolute() << endl;
            }
            s9= s9->getNext();
        }
        cout << "\t\t共计【" << ssp << "】条信息" << endl;
        if (ssp == 0) {
            cout << "\t\t无信息反馈!" << endl;
            system("pause");
            break;
        }
        cout << "\t\t输入学号回复信息( 0 退出):";
        int dd = 0 ;
        cin >> dd;
        if (dd == 0)break;
        while (s6 != NULL)
        {
            if (s6->getID() == dd)
            {
                break;
            }
            s6 = s6->getNext();
        }
        if (s6 == NULL)
        {
            cout << "\t\t未查询到此学号!" << endl;
            system("pause");
            continue;
        }
        cout << "\t\t请写回复信息:";
        cin >> s6->getSolute();
        cout << "\t\t回复完毕!" << endl;
        Writefile("E://1C//学生管理//1.txt");
        cout << "\t\t继续回复按1,退出按0" << endl;
        string ci = " ";
        while (1)
        {
            cout << "\t\t选择:";
            cin >> ci;
            if (ci == "0")break;
            if (ci == "1")break;
            cout << "\t\t无此选项!重选:" << endl;
        }
        if (ci == "0")break;
        system("pause");
    }
}`
  1. 退出教师界面。
  1. 学生端功能实现
  1. 查看全校成绩:查看全校成绩,按总分排序。
  1. 查看个人成绩:搜索个人的信息。
  1. 查看个人能力:系统根据所得成绩分析你的能力,以及显示各科排名及总成绩排名。
  1. 递交反馈信息:写反馈信息发送到教师端。
  1. 查看反馈信息:可看自己提出的问题是否解决,以及其他人的反馈信息。
  1. 退出学生界面。
相关推荐
NuyoahC15 分钟前
算法笔记(十一)——优先级队列(堆)
c++·笔记·算法·优先级队列
FL16238631291 小时前
[C++]使用纯opencv部署yolov11-pose姿态估计onnx模型
c++·opencv·yolo
sukalot1 小时前
windows C++-使用任务和 XML HTTP 请求进行连接(一)
c++·windows
ぃ扶摇ぅ1 小时前
Windows系统编程(三)进程与线程二
c++·windows
Mr.Z.4112 小时前
【历年CSP-S复赛第一题】暴力解法与正解合集(2019-2022)
c++
Death2002 小时前
使用Qt进行TCP和UDP网络编程
网络·c++·qt·tcp/ip
郭二哈3 小时前
C++——list
开发语言·c++·list
黑不溜秋的3 小时前
C++ 语言特性29 - 协程介绍
开发语言·c++
一丝晨光3 小时前
C++、Ruby和JavaScript
java·开发语言·javascript·c++·python·c·ruby
￴ㅤ￴￴ㅤ9527超级帅4 小时前
LeetCode hot100---二叉树专题(C++语言)
c++·算法·leetcode