C++寝室卫生管理系统 C++实现寝室卫生管理系统

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

C++寝室卫生管理系统 C++实现寝室卫生管理系统

编程小白2.0   2022-03-16 我要评论
想了解C++实现寝室卫生管理系统的相关内容吗,编程小白2.0在本文为您仔细讲解C++寝室卫生管理系统的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:C++寝室卫生管理,C++卫生管理系统,C++寝室管理系统,下面大家一起来学习吧。

介绍:

当初写程序的时候很多知识都不足,我算是一个半路出家的。当时在另一课本上看到goto语句,感觉挺有趣的,就用上了,但goto语句,不适合很长的代码,由易造成逻辑混乱,也可以换成do-while语句。

我设计了输出表格框架,再循环输出数据,为使数据对齐,使用setw(),setw(int n)是c+ +中在输出操作中使用的字段宽度设置,设置输出的域宽,n表示字段宽度。此函数只对紧接着的输出有效,紧接着的输出结束后又变回默认的域宽。当后面紧跟着的输出字段长度小于n的时候,在该字段前面用空格补齐;当输出字段长度大于n时,全部整体输出。头文件为:iomanip;

输入密码时,如非回车键,皆输出“*”,通过getch()函数实现,此函数是一个不回显函数,当用户按下某个字符时,函数自动读取,无需按回车键,所在头文件:conio.h,int __cdecl getch();声明,等,还用了一些算法,在此先不做详细介绍。

一、基本功能

1.(管理员,需要密码)实现成绩录入(地面卫生、床铺、物品摆放及其他)成绩求和和保存、修改及删除

2.(学生查询)实现显示所有寝室成员(按寝室号排序和按成绩排序)、显示自己寝室成绩-输入号(按寝室号排序和按成绩排序)、本周文明寝室、本周差评寝室

二、扩展功能

1.管理员也可对学生寝室信息包括寝室号,寝室成员进行基本管理,包括增,删,查,改等功能

2.对系统使用成员实现所有寝室成绩的查询,显示功能(可按寝室号排序或成绩排序),学生也可查看其他寝室相关信息

三、功能结构

 本系统的总体功能结构是:首先学生可以查看寝室卫生检查结果信息,管理员具有唯一的帐号以及密码,登录后可以对基本数据进行增删改查等操作。

总体分为五大模块:寝室基本信息录入模块,寝室基本信息修改模块,寝室基本信息查询模块,寝室基本信息显示模块,寝室基本信息保存模块。总体功能结构图如图所示:

代码如下: 

#include<iostream>
#include<conio.h>
#include<fstream>
#include<iomanip>
#include<string>
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
#define M 50//表长
typedef int shu;
//寝室信息结构
typedef struct {
    shu ground;//地面卫生
    shu bed;//床铺
    shu article;//物品摆放
    shu other;//其他
    shu grade;//总成绩
    char member[50];//寝室成员
    char number[10];//寝室号
    int Total;
}Student, St;
 
Student S[M];
 
//1、定义清屏函数
void Clear()
{
    system("pause");
    system("cls");
}
//2、定义显示函数表头
void showhead()
{
    cout << "\n********************欢迎使用宿舍卫生管理系统********************\n " << endl;
    cout << "\n    显示方式:\n " << endl;
    cout << "\t①按成绩显示\n" << endl;
    cout << "\t②按寝室显示\n" << endl;
    cout << "\t③返回上级\n\n" << endl;
    cout << "\t    请选择:";
}
//3、登录函数
void load()
{
    int n1; int i;
loop:cout << "\n********************欢迎使用宿舍卫生管理系统********************\n\n" << endl;
    cout << "\t\t帐号:";
    cin >> n1;
    cout << "\t\t密码:";
    char a[40], b[14] = { "20190228" };
    for (i = 0;; i++)
    {
        int __cdecl getch();
        a[i] = getch();
        if (a[i] != '\r')
            cout << "*";
        else {
            a[i] = '\0';
            if (strcmp(a, b) == 0 && n1 == 20190228)
            {
                cout << "\n登录成功。。。。\n" << endl;
                Clear();
            }
            else {
                cout << "\n用户名或密码错误。。。\n" << endl;
                Clear();
                goto loop;
            }
            break;
        }
    }
}
//4、定义查询函数表头
void searchheader()
{
    cout << "\n********************欢迎使用宿舍卫生管理系统********************\n\n " << endl;
    cout << "\t①按成绩查询\n" << endl;
    cout << "\t②按寝室查询\n" << endl;
    cout << "\t③返回上级\n\n" << endl;
    cout << "    请选择:";
}
//5、定义录入函数
void Add(Student* S)
{
    char ch[10];
    char ch1[2] = { "0" };
    do
    {
        cout << "\n********************欢迎使用宿舍卫生管理系统********************\n\n" << endl;
        cout << "\t****************学生信息录入****************\n";
        cout << "请输入第" << S[0].Total + 1 << "个寝室的信息\n";
        cout << "寝 室 号:";
        cin >> S[S[0].Total + 1].number;
        cout << " 成  员 :";
        cin >> S[S[0].Total + 1].member;
        cout << "地面卫生:";
        cin >> S[S[0].Total + 1].ground;
        cout << " 床  铺 :";
        cin >> S[S[0].Total + 1].bed;
        cout << "物品摆放:";
        cin >> S[S[0].Total + 1].article;
        cout << " 其  他 :";
        cin >> S[S[0].Total + 1].other;
        cout << "总 成 绩:";
        S[S[0].Total + 1].grade = S[S[0].Total + 1].ground + S[S[0].Total + 1].bed + S[S[0].Total + 1].article + S[S[0].Total + 1].other;
        cout<< S[S[0].Total + 1].grade<<endl;
        S[0].Total++;
        cout << "按数字“0”退出,任意键继续录入: " ;
        cin >> ch;
        system("cls");//清屏函数
    } while (strcmp(ch, ch1) != 0);
}
//6、定义显示函数 
void Display_All(Student* S)
{
 
    cout << "\n" << endl;
    int i;
    cout << "                                                                                                   " << endl;
    cout << "  ———————————————————————————————————————————————— " << endl;
    cout << " |                                     学 生 宿 舍 信 息                                          |" << endl;
    cout << " |————————————————————————————————————————————————|" << endl;
    cout << " | 寝室号 | 总成绩 |              寝  室  成  员              |地面卫生| 床  铺 |物品摆放| 其  他 |" << endl;
    if (S[0].Total > 0)
    {
        for (i = 1; i <= S[0].Total; i++)
        {
            cout << " |————|————|—————————————————————|————|————|————|————|" << endl;
            cout << " |" << setw(8) << S[i].number << "|" << setw(8) << S[i].grade << "|";
            cout << setw(42) << S[i].member << "|" << setw(8) << S[i].ground << "|";
            cout << setw(8) << S[i].bed << "|" << setw(8) << S[i].article << "|";
            cout << setw(8) << S[i].other << "|" <<endl ;
        }
    }
    else
    {
        cout << " |————————————————————————————————————————————————|" << endl;
        cout << "                                没 有 任 何 学 生 信 息                                            " << endl;
    }
    cout << "  ———————————————————————————————————————————————— " << endl;
}
//7、排序函数按照成绩从小到大排序(快排)
int Partition(Student* S, int low, int high)
{//对顺序表中的子表进行一趟排序,返回枢轴位置
    shu  pivotkey;
    Student i;
    i = S[low];//用i作枢轴记录
    pivotkey = S[low].grade;//枢轴成绩保存在pivokey中
    while (low < high)//从表的两端交替的向中间扫描 
    {
        while (low < high && S[high].grade >= pivotkey) --high;
        S[low] = S[high];//将比枢轴记录小的记录移到低端
        while (low < high && S[low].grade <= pivotkey) ++low;
        S[high] = S[low];//比枢轴记录大的记录移到高端
    }
    S[low] = i;//枢轴记录到位 
    return low; //返回枢轴位置 
}
void QSort(Student* S, int low, int high)
{
    //对顺序表中的子表进行快速排序
    int pivotloc;
    if (low < high) //长度大于1
    {
        pivotloc = Partition(S, low, high);//将子表一分为二,pivotloc是枢轴位置
        QSort(S, low, pivotloc - 1);//对左子表递归排序
        QSort(S, pivotloc + 1, high);//对右子表递归排序
    }
}
void Sort_grade(Student* S)
{//对顺序表L进行快速排序
    QSort(S, 1, S[0].Total);
}
//8、排序函数按照寝室号从小到大排序(堆排序) 
void HeapAdjust(Student* S, int s, int m)
{
    Student rc; int j;
    rc = S[s];
    for (j = 2 * s; j <= m; j *= 2)//沿number较大的孩子结点向下筛选
    {
        if (j < m&& strcmp(S[j].number, S[j + 1].number)<0) ++j;//j为number较大的记录下标
        if (strcmp(rc.number , S[j].number)>=0) break;//rc应插入在位置s上
        S[s] = S[j]; s = j;
    }
    S[s] = rc;
}
void CreatHeap(Student* S)
{//把无序序列S[1...n]建成大根堆
    int n, i;
    n = S[0].Total;
    for (i = n / 2; i > 0; --i)//反复调用HeapAdjust
        HeapAdjust(S, i, n);
}
void Sort_number(Student* S)
{//对顺序表S进行堆排序
    int i;
    Student x;
    CreatHeap(S);
    for (i = S[0].Total; i > 1; --i)
    {
        x = S[1];//将堆顶记录和当前未经排序子序列S[1...i]中最后一个记录互换
        S[1] = S[i];
        S[i] = x;
        HeapAdjust(S, 1, i - 1);//将S[1..i-1]重新调整为大根堆
    }
}
//9、查询函数以成绩为关键字进行查询(折半查找)
void searh_grade(Student* S)
{
    int high, low, mid;
    int j=0;
    shu grade;
    low = 1;
    high = S[0].Total;
    cout << "请输入你要查找学生的成绩:";
    cin >> grade;
    Sort_grade(S);//声明排序函数按照成绩从小到大排序(快排)
    cout << "\n\n" << endl;
    cout << "  ———————————————————————————————————————————————— " << endl;
    cout << " |                                     所 查 找 寝 室 信 息                                       |" << endl;
    cout << " |————————————————————————————————————————————————|" << endl;
    cout << " | 寝室号 | 总成绩 |               寝  室  成  员             |地面卫生| 床  铺 |物品摆放| 其  他 |" << endl;
    if (grade== S[1].grade)
    {
        cout << " |————|————|—————————————————————|————|————|————|————|" << endl;
        cout << " |" << setw(8) << S[1].number << "|" << setw(8) << S[1].grade << "|";
        cout << setw(42) << S[1].member << "|" << setw(8) << S[1].ground << "|";
        cout << setw(8) << S[1].bed << "|" << setw(8) << S[1].article << "|";
        cout << setw(8) << S[1].other <<  "|"<<endl;
        j = 1;
    }
    else
        if (grade == S[(S[0].Total)].grade)
        {
            cout << " |————|————|—————————————————————|————|————|————|————|" << endl;
            cout << " |" << setw(8) << S[S[0].Total].number << "|" << setw(8) << S[S[0].Total].grade << "|";
            cout << setw(42) << S[S[0].Total].member << "|" << setw(8) << S[S[0].Total].ground << "|";
            cout << setw(8) << S[S[0].Total].bed << "|" << setw(8) << S[S[0].Total].article << "|";
            cout << setw(8) << S[S[0].Total].other << "|" << endl;
            j = 1;
        }
        else
        {
            while (low <= high)
            {
                mid = (low + high) / 2;
                if (grade == S[mid].grade)
                {
                    int i = mid;
                    cout << " |————|————|—————————————————————|————|————|————|————|" << endl;
                    cout << " |" << setw(8) << S[i].number << "|" << setw(8) << S[i].grade << "|";
                    cout << setw(42) << S[i].member << "|" << setw(8) << S[i].ground << "|";
                    cout << setw(8) << S[i].bed << "|" << setw(8) << S[i].article << "|";
                    cout << setw(8) << S[i].other << "|" << endl;
                    j = 1;
                    break;
                }
                else
                    if (grade > S[mid].grade)
                        low = mid + 1;
                    else
                        high = mid - 1;
            }
        }
    if (j != 1)
    {
        cout << " |————————————————————————————————————————————————|" << endl;
        cout << " |                                     查 无 此 寝 室 信 息                                       |" << endl;
    }
    cout << "  ———————————————————————————————————————————————— " << endl;
}
//10、查询函数以寝室号为关键字进行查询(折半查找)
void searh_number(Student* S)
{
    int high, low, mid;
    char number[20];
    int j=0;
    low = 1;
    high = S[0].Total;
    cout << "请输入你要查找学生的寝室号:";
    cin >> number;
    Sort_number(S);//声明排序函数按照寝室号从小到大排序(堆排序)
    cout << "'\n\n" << endl;
    cout << "  ———————————————————————————————————————————————— " << endl;
    cout << " |                                     所 查 找 的 寝 室 信 息                                    |" << endl;
    cout << " |————————————————————————————————————————————————|" << endl;
    cout << " | 寝室号 | 总成绩 |               寝  室  成  员             |地面卫生| 床  铺 |物品摆放| 其  他 |" << endl;
    while (low <= high)
    {
        mid = (low + high) / 2;
        if (strcmp(number, S[mid].number) == 0)
        {
            int i = mid; j = 1;
            cout << " |————|————|—————————————————————|————|————|————|————|" << endl;
            cout << " |" << setw(8) << S[i].number << "|" << setw(8) << S[i].grade << "|";
            cout << setw(42) << S[i].member << "|" << setw(8) << S[i].ground << "|";
            cout << setw(8) << S[i].bed << "|" << setw(8) << S[i].article << "|";
            cout << setw(8) << S[i].other << "|" << endl;
 
            for (i = mid + 1; i <= high; i++)
            {
                if (strcmp(number, S[i].number) == 0)
                {
                    cout << " |————|————|—————————————————————|————|————|————|————|" << endl;
                    cout << " |" << setw(8) << S[i].number << "|" << setw(8) << S[i].grade << "|";
                    cout << setw(42) << S[i].member << "|" << setw(8) << S[i].ground << "|";
                    cout << setw(8) << S[i].bed << "|" << setw(8) << S[i].article << "|";
                    cout << setw(8) << S[i].other << "|" << endl;
                }
            }
            for (i = mid - 1; i >= low; i--)
            {
                if (strcmp(number, S[i].number) == 0)
                {
                    cout << " |————|————|—————————————————————|————|————|————|————|" << endl;
                    cout << " |" << setw(8) << S[i].number << "|" << setw(8) << S[i].grade << "|";
                    cout << setw(42) << S[i].member << "|" << setw(8) << S[i].ground << "|";
                    cout << setw(8) << S[i].bed << "|" << setw(8) << S[i].article << "|";
                    cout << setw(8) << S[i].other << "|" << endl;
                }
            }
            break;
        }
        else
            if (strcmp(number, S[mid].number) > 0)
                low = mid + 1;
            else
                high = mid - 1;
    }
    if (j != 1)
    {
        cout << " |————————————————————————————————————————————————|" << endl;
        cout << " |                                     查 无 此 寝 室 信 息                                       |" << endl;
    }
    cout << "  ———————————————————————————————————————————————— " << endl;
}
//11、判断是否是文明寝室
void y_n_number(Student* S)
{
    int high, low, mid;
    char number[20];
    int j=0;
    low = 1;
    high = S[0].Total;
    cout << "请输入你要查找学生的寝室号:";
    cin >> number;
    Sort_number(S);//声明排序函数按照寝室号号从小到大排序(堆排序)
    while (low <= high)
    {
        mid = (low + high) / 2;
        if (strcmp(number, S[mid].number) == 0)
        {
            int i = mid; j = 1;
            if (S[i].grade >= 80)
                cout << "\n\n本周文明寝室\n\n";
            else cout << "\n\n本周差评寝室\n\n";
 
            for (i = mid + 1; i <= high; i++)
            {
                if (strcmp(number, S[i].number) == 0)
                {
                    if (S[i].grade >= 80)
                        cout << "\n\n本周文明寝室\n\n";
                    else cout << "\n\n本周差评寝室\n\n";
                }
            }
            for (i = mid - 1; i >= low; i--)
            {
                if (strcmp(number, S[i].number) == 0)
                {
                    if (S[i].grade >= 80)
                        cout << "\n\n本周文明寝室\n\n";
                    else cout << "\n\n本周差评寝室\n\n";
                }
            }
            break;
        }
        else
            if (strcmp(number, S[mid].number) > 0)
                low = mid + 1;
            else
                high = mid - 1;
    }
    if (j != 1)
    {
        cout << "  ———————————————————————————————————————————————— " << endl;
        cout << " |                                            查 无 此 寝 室 信 息                                |" << endl;
        cout << "  ———————————————————————————————————————————————— " << endl;
    }
}
//12、定义修改学生信息表头函数
void Exchangehead()
{
    cout << "\n********************欢迎使用宿舍卫生管理系统********************\n\n " << endl;
    cout << "    ********************修改菜单********************\n " << endl;
    cout << "\t①单个删除信息\n" << endl;
    cout << "\t②删除全部信息\n" << endl;
    cout << "\t③修改寝室信息\n" << endl;
    cout << "\t④返回上级菜单\n\n" << endl;
    cout << "    请选择:";
}
//13、写文件函数
void Keep(Student* S)
{
    ofstream output("学生宿舍信息.txt");//初始化输出流对象
    if (output.is_open())
    {
        int i, j;
        j= S[0].Total;
        output << j<<endl;
        for (i = 1; i <= S[0].Total; i++)
        {
            output << S[i].number<<endl;
            output << S[i].grade<<endl;
            output << S[i].member << endl;
            output << S[i].ground << endl;
            output << S[i].bed << endl;
            output << S[i].article << endl;
            output << S[i].other << endl;
        }
    }
    output.close();
}
//14、读文件函数
void Input(Student* S)
{
    ifstream input("学生宿舍信息.txt",ios::in);//初始化输出流对象
    if (input.is_open())
    {
        int i,j;
        input >> j;
        S[0].Total = j;
        for (i = 1; i <= S[0].Total; i++)
        {
            input >> S[i].number;
            input >> S[i].grade;
            input >> S[i].member;
            input >> S[i].ground;
            input >> S[i].bed;
            input >> S[i].article;
            input>> S[i].other;
        }
    }
    input.close();
}
//主函数开始
void main()
{
    Student S[M];
    S[0].Total = 0;
    Input(S);
loop1:cout << "\n********************欢迎使用宿舍卫生管理系统********************\n" << endl;
    cout << "\n    请选择以何身份登录系统:\n\n\n";
    cout << "\t1、管理员\n\n";
    cout << "\t2、学生\n\n";
    cout << "\t3、退出系统\n\n";
    cout << "\t请选择:";
    int x;
    cin >> x;
    
    switch (x)
    {
    case 1: {
        system("cls");//清屏函数;
        load();//调用登录函数
        int choicem;
        do {
            cout << "\n********************欢迎使用宿舍卫生管理系统********************\n" << endl;
            cout << "\t ********************主菜单********************\n " << endl;
            cout << "\t①录入学生信息\n" << endl;
            cout << "\t②显示学生信息.\n" << endl;
            cout << "\t③查询学生信息\n" << endl;
            cout << "\t④修改学生信息\n" << endl;
            cout << "\t⑤存储学生信息\n" << endl;
            cout << "\t⑥返回上级\n" << endl;
            cout << "\t⑦退出系统\n\n" << endl;
            cout << "\t请选择:";
            cin >> choicem;
            
            switch (choicem)
            {
            case 1: // 录入信息.
            {
                system("cls");//清屏函数
                Add(S); // 调用录入信息函数
                system("cls");//清屏函数
                Keep(S);
                break;
            }
            case 2: // 显示学生信息
            {
                system("cls");//清屏函数
                int choice2;
            loop2:showhead();
                cin >> choice2;
                if (choice2 == 1)
                {
                    Sort_grade(S);//调用排序函数按照成绩从小到大排序(快排) 
                    system("cls");//清屏函数
                    cout << "按成绩大小显示信息." << endl;
                    Display_All(S); // 调用显示学生信息函数
                    Keep(S);
                    Clear();
                    goto loop2;
                    system("cls");//清屏函数
                }
                else if (choice2 == 2)
                {
                    Sort_number(S);//排序函数按照寝室号从小到大排序(堆排序)
                    system("cls");//清屏函数
                    cout << "按寝室号大小显示信息." << endl;
                    Display_All(S); // 调用显示学生信息函数
                    Keep(S);
                    Clear();
                    goto loop2;
                    system("cls");//清屏函数
                }
                else if (choice2 == 3)
                {
                    system("cls");//清屏函数
                    break;
                }
                else {
                    cout << "\n\t输入错误,请重新输入。。。。 " << endl;
                    Clear();
                    goto loop2;
                }
            }
            case 3: // 查询学生信息、
            {
                system("cls");//清屏函数
                int choice3;
            loop3:searchheader();//调用查询表头函数
                cin >> choice3;
                if (choice3 == 1)//按成绩查询
                {
                    system("cls");//清屏函数
                    searh_grade(S);//查询函数以成绩为关键字进行查询(折半查找)
                    Clear();
                    goto loop3;
                }
                else if (choice3 == 2)//按寝室号查询
                {
                    system("cls");//清屏函数
                    searh_number(S);//调用查询函数以寝室号为关键字进行查询(折半查找)
                    Clear();
                    goto loop3;
                }
                else if (choice3 == 3)//返回上级菜单
                    system("cls");//清屏函数
                else // 输入错误
                {
                    cout << "\n\n\t选择错误,请重新输入。。。 \n" << endl;
                    Clear();
                    goto loop3;
                }
                break;
            }
            case 4: // 修改学生信息
            {
                system("cls");//清屏函数
            loop4: Exchangehead();//调用修改学生信息表头函数
                int choice1;
                cin >> choice1;
 
                if (choice1 == 1)//单个删除
                {
                    int i, j;
                    int flag = 0; // 用来判断表中是否存在所要册除的学生的信息.
                    char number[20];
 
                    system("cls");//清屏函数
                    cout << "请输入你要删除寝室的寝室号:";
                    cin >> number;
                    for (i = 1; i <= S[0].Total; i++)
                        if (strcmp(S[i].number, number) == 0)
                            flag = i;
                    if (!flag) {
                        cout << "\n \n\t你所要删除的信息在表中不存在! \n" << endl;
                        Clear();
                        goto loop4;
                    }
                    else {
                        for (i = flag; i <= S->Total; i++)
                        {
                            j = i + 1;
                            S[i] = S[j];
                        }
                        S[0].Total--;
                        cout << "\n\t删除成功!\n" << endl;
                        Clear();
                        Keep(S);
                        goto loop4;
                    }
                }
                else if (choice1 == 2) // 全部删除
                {
                    system("cls");//清屏函数
                    S[0].Total = 0;
                    cout << "\n\n\n          册除成功。。。。。\n\n" << endl;
                    Clear();
                    Keep(S);
                    goto loop4;
                }
                else if (choice1 == 3)//修改信息
                {
                    int i;
                    int flag = 0; // 用来判断表中是否存在所要修改的学生的信息.
                    char number[20];
                    system("cls");//清屏函数
                    cout << "请输入你要修改的寝室的寝室号:";
                    cin >> number;
                    for (i = 1; i <= S[0].Total; i++)
                        if (strcmp(S[i].number, number) == 0)
                            flag = i;
                    if (!flag)
                    {
                        cout << "\n\t你所要修改的学生在表中不存在! \n" << endl;
                        Clear();
                        goto loop4;
                    }
                    else
                    {
                        cout << "\n\n" << endl;
                        cout << "  ———————————————————————————————————————————————— " << endl;
                        cout << " |                                     修 改 前 的 寝 室 信 息                                    |" << endl;
                        cout << " |————————————————————————————————————————————————|" << endl;
                        cout << " | 寝室号 | 总成绩 |              寝  室  成  员              |地面卫生| 床  铺 |物品摆放| 其  他 |" << endl;
                        cout << " |————|————|—————————————————————|————|————|————|————|" << endl;
                        cout << " |" << setw(8) << S[flag].number << "|" << setw(8) << S[flag].grade << "|";
                        cout << setw(42) << S[flag].member << "|" << setw(8) << S[flag].ground << "|";
                        cout << setw(8) << S[flag].bed << "|" << setw(8) << S[flag].article << "|";
                        cout << setw(8) << S[flag].other << "|" << endl;
                        cout << "  ———————————————————————————————————————————————— " << endl;
                        cout << "********************学生信息修改********************\n";
                        cout << " 寝室号 :";
                        cin >> S[flag].number;
                        cout << " 成  员 :";
                        cin >> S[flag].member;
                        cout << "地面卫生:";
                        cin >> S[flag].ground;
                        cout << " 床  铺 :";
                        cin >> S[flag].bed;
                        cout << "物品摆放:";
                        cin >> S[flag].article;
                        cout << " 其  他 :";
                        cin >> S[flag].other;
                        cout << " 总成绩 :";
                        S[flag].grade = S[flag].ground + S[flag].bed + S[flag].article + S[flag].other;
                        cout << S[flag].grade;
                        cout << "\n";
                        cout << "  ———————————————————————————————————————————————— " << endl;
                        cout << " |                                     修 改 后 的 寝 室 信 息                                    |" << endl;
                        cout << " |————————————————————————————————————————————————|" << endl;
                        cout << " | 寝室号 | 总成绩 |              寝  室  成  员              |地面卫生| 床  铺 |物品摆放| 其  他 |" << endl;
                        cout << " |————|————|—————————————————————|————|————|————|————|" << endl;
                        cout << " |" << setw(8) << S[flag].number << "|" << setw(8) << S[flag].grade << "|";
                        cout << setw(42) << S[flag].member << "|" << setw(8) << S[flag].ground << "|";
                        cout << setw(8) << S[flag].bed << "|" << setw(8) << S[flag].article << "|";
                        cout << setw(8) << S[flag].other << "|" << endl;
                        cout << "  ———————————————————————————————————————————————— " << endl;
                        Clear();
                        Keep(S);
                        goto loop4;
                    }
                }
                else
                    if (choice1 == 4)//返回上级菜单
                    {
                        system("cls");//清屏函数
                        break;
                    }
                    else//输入错误
                    {
                        cout << "\n\t选择错误,请重新选择。。。\n" << endl;
                        Clear();
                        goto loop4;
                    }
            }
            case 5: // 存储学生信息、
            {
                system("cls");//清屏函数
                Keep(S);
                cout << "\n********************欢迎使用宿舍卫生管理系统********************\n " << endl;
                cout << "\n\t存储成功。。。。。\n" << endl;
                Clear();
                break;
            }
            case 6: //返回上级
            {
                system("cls");//返回上级
                goto loop1;
            }
            case 7:break; // 退出管理系统
            default: {
                cout << "\n\n\t输入错误,请重新选择。。。\n\n" << endl;
                Clear();
                break;
            }
            }
        } while (choicem != 7);
        break;
    }
    case 2: {
        system("cls");//清屏函数;
        int choice;
        do {
            cout << "\n********************欢迎使用宿舍卫生管理系统********************\n " << endl;
            cout << "\n    显示方式:\n " << endl;
            cout << "\t①按寝室查询\n" << endl;
            cout << "\t②按寝室显示\n" << endl;
            cout << "\t③按成绩显示\n" << endl;
            cout << "\t④本周寝室评价\n" << endl;
            cout << "\t⑤返回上级\n" << endl;
            cout << "\t⑥退出系统\n\n" << endl;
            cout << "    请选择:";
            cin >> choice;
            if (choice == 1)//按成绩查询
            {
                system("cls");//清屏函数
                searh_number(S);// 查询函数以寝室号为关键字进行查询(折半查找)
                Clear();
 
            }
            else if (choice == 2)//按寝室号显示
            {
                system("cls");//清屏函数
                Sort_number(S);//排序函数按照寝室号从小到大排序(堆排序)
                Display_All(S);//显示函数
                Clear();
            }
            else if (choice == 3)//按成绩显示
            {
                Sort_grade(S);//调用排序函数按照成绩从小到大排序(快排) 
                system("cls");//清屏函数
                Display_All(S); // 调用显示学生信息函数
                Clear();
            }
            else if (choice == 4)
            {
                system("cls");//清屏函数
                y_n_number(S);//是否是文明寝室ok
                Clear();
            }
            else if (choice == 5)//返回上级
            {
                system("cls");//清屏函数
                goto loop1;
            }
            else if(choice == 6)
            {
                break;
            }
            else {
                cout << "\n\t输入错误,请重新输入。。。。 \n\n" << endl;
                Clear();
            }
        } while (choice != 5);
        break;
    }
    case 3:break;
    default: {
        cout << "\n\n\t输入错误,请重新输入。。。\n\n"<<endl;
        Clear();
        goto loop1;
    }
    }
}

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们