C++课程设计学生宿舍管理信息系统

 

青岛农业大学c++课 程 设 计报 告

 

 

 

 

学院、系:

青岛农业大学理信学院

专业名称:

计算机科学与技术

课程设计科目

面向对象程序课程设计

学生姓名:

董松

指导教师:

苏万力

完成时间:

2018年4月 23 日--- 5 月 5 日

 

 

 

 

 

 

 

 

学生宿舍管理信息系统

一、设计任务与目标

随着高校的扩招,学生人数巨增,传统的管理方法已经不能适合高校学生宿舍管理的需要。本系统的使用,能大大减少学生处管理者的重复劳动,是学校管理的得力助手。其主要功能模块如下:

(1)宿舍基本信息模块:添加、修改、查询、删除宿舍基本信息。

(2)学生入住模块:学生基本信息、缴费、入住、退房信息等。

(3)卫生检查:对宿舍卫生检查、评比、统计等

(4)水电收费:对超出规定部分的水电的收费管理

(5)房屋报修:对报修情况的登记、时间安排、修理结果检查等。

(6)外来人员登记:对外来人员的登记、管理等。

(7)其他功能可根据需要自行扩充,并请在课程设计报告中详细说明!

二、课程设计方案

1、功能扩建,宿舍查寝。为了学生的安全起见,生活部每天晚上进行随机宿舍查寝,用到随机函数rand();进行一个页面使用。

 

2、在课程设计参数传递,以及地址传递用到数据结构中学到的链表,用到了struct以及c++中的类

 

3、用vs进行编译,编程语言为C++,没有用到数据库,使用链表储存数据以及用文本进行数据读取与保存。在页面上用到清屏函数与while函数进行页面之间的转换,并且每个页面都进行了链表存储和文本读取。在每个链表存储中都可以实现信息的增、删、改、查,对数据进行再次利用。

 

4、该程序的由多种函数实现,每个函数具有不同的功能,主要有主菜单函数,插入功能子菜单函数,查找功能子菜单函数,学生信息录入函数,显示函数,排序函数,插入函数以及查找函数。在每个区域中会调用不同的函数来实现主要的功能。比如,在宿舍输出这个功能里调用show函数;在插入功能里调用子菜单函数;在显示信息时调用排序函数先对需要输出的信息进行排序,然后再输出;在查找功能里会调用查找函数来进行查找。

 

  

 

三、程序框图或流程图

 

 

 

 

 

 

 

 

四、全部源程序清单

1、头文件:

#include "Sushe.h"

 

#define MAX_NUM 10000000

#include <String>

#include<ctime>

#include <fstream>

using namespace std;

 

struct StuNode{

long stu_num=0;

char stu_nam[40];

char stu_cla[40];

char stu_sus[40];

char stu_chu[40];

StuNode *nextstu;

};

 

class Sushe{

StuNode *StuListHead;

public:

Sushe();      //构造函数

~Sushe();     //析构函数

void CreatSinfo();  //创建学生信息

void StuInsert(int num, char* nam, char* cla, char* sus, char* chu);  //插入学生信息

void StuDelete(int num);    //删除学生信息

StuNode *StuFind(int num);   //查找学生信息,传入参数学号

void StuModify(int num, char* nam, char* cla, char* sus, char* chu);   //修改学生信息

void StuRead();        //从文件读入学生信息

void StuSave();        //保存学生信息到文件

void StuQuit();

void ShowInfo();           //遍历输出学生信息

void panduan(int stu_num);

 

};

void pdwei(int stu_num)

{

while (stu_num<10000 || stu_num>99999)

{

cout << "你输入的学号不正确,请输入一个五位数的学号" << endl;

cout << "学号:";

cin >> stu_num;

}

}

 

 void Sushe::panduan(int stu_num)

 {

 pdwei(stu_num);

 StuNode *p;

 for (p = StuListHead->nextstu; p != NULL; p = p->nextstu)

 {

 while (p->stu_num == stu_num)

 {

 cout << "学号重复,请重新输入!" << endl;

 cout << "学号:";

 cin >> stu_num;

 }

 }

 }

 

 

void SuMenu()

{

time_t t;

time(&t);

cout << "---------------------------------宿舍基本信息模块-------------------------------" << endl;

cout << "\t\t\t 本地时间:" << ctime(&t);

cout << "--------------------------------------------------------------------------------\n" << endl;

cout << "\t\t 1.读入学生宿舍信息  " << endl;

cout << "\t\t 2.录入多个宿舍信息  " << endl;

cout << "\t\t 3.添加单个宿舍信息  " << endl;

cout << "\t\t 4.删除已有宿舍信息  " << endl;

cout << "\t\t 5.查找已有宿舍信息  " << endl;

cout << "\t\t 6.修改已有宿舍信息  " << endl;

cout << "\t\t 9.输出所有宿舍信息  " << endl;

cout << "\t\t 10.保存现有宿舍信息 " << endl;

cout << "\t\t 0.返回信息主菜单   " << endl;

cout << "\n\t\t请选择:";

}

 

Sushe::Sushe()   //构造函数

{

StuListHead = new StuNode;

StuListHead->nextstu = NULL;

StuListHead->stu_num = 0;

}

 

Sushe::~Sushe()       //析构函数

{

StuNode *p;

while (StuListHead)

{

p = StuListHead;

StuListHead = StuListHead->nextstu;

delete p;

}

StuListHead = NULL;

}

 

void Sushe::CreatSinfo()     //创建学生信息表

{

int n;

StuNode *p, *s;

p = StuListHead;

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

cin >> n;

for (int i = 1; i <= n; i++)

{

s = new StuNode;

cout << "学号:"; cin >> s->stu_num;

panduan(s->stu_num);

cout << "姓名:"; cin >> s->stu_nam;

cout << "班级:"; cin >> s->stu_cla;

cout << "宿舍:"; cin >> s->stu_sus;

cout << "床号:"; cin >> s->stu_chu;

s->nextstu = p->nextstu;

p->nextstu = s;

p = p->nextstu;

}

if (p == NULL)   //判断学生信息表是否创建成功

{

cout << "创建失败请重新创建!" << endl;

CreatSinfo();

}

}

 

void Sushe::ShowInfo()      //遍历输出

{

StuNode *p;

cout << "学号" << '\t' << "姓名" << '\t' << "班级" << '\t' << "宿舍" << '\t' << "床号" << endl;

for (p = StuListHead->nextstu; p != NULL; p = p->nextstu)

{

cout << p->stu_num << '\t' << p->stu_nam << '\t' << p->stu_cla << '\t' << p->stu_sus << '\t' << p->stu_chu << endl;

}

}

 

 

void Sushe::StuInsert(int num, char* nam, char* cla, char* sus, char* chu)     //插入学生信息(头插法)

{

StuNode *s, *p;

s = new StuNode;

s->stu_num = num;

strcpy(s->stu_nam, nam);

strcpy(s->stu_cla, cla);

strcpy(s->stu_sus, sus);

strcpy(s->stu_chu, chu);

p = StuListHead;

s->nextstu = p->nextstu;

p->nextstu = s;

}

 

void Sushe::StuDelete(int num)

{

StuNode *p, *ptemp;

p = StuListHead;

ptemp = p;

while (p->nextstu && p->stu_num != num)   //循环终止条件为p->nextstu不为空 而且没有找到相应学号的学生

{

ptemp = p;

p = p->nextstu;

}

if (p->stu_num == num)

{

ptemp->nextstu = p->nextstu;

delete p;

}

else

{

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

}

}

 

StuNode *Sushe::StuFind(int num)

{

StuNode *p;

p = StuListHead->nextstu;

while (p->nextstu && p->stu_num != num)   //循环终止条件为p->nextstu不为空 而且没有找到相应学号的学生

{

p = p->nextstu;

}

if (p->stu_num == num)

{

return p;

}

else

{

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

return NULL;

}

}

 

void Sushe::StuModify(int num, char* nam, char* cla, char* sus, char* chu)   //修改信息

{

StuNode *ItemStu = StuFind(num);   //直接调用查找函数

if (ItemStu != NULL)

{

ItemStu->stu_num = num;

strcpy(ItemStu->stu_nam, nam);

strcpy(ItemStu->stu_cla, cla);

strcpy(ItemStu->stu_sus, sus);

strcpy(ItemStu->stu_chu, chu);

cout << "修改成功!" << endl;

}

}

void Sushe::StuRead()    //从文件读入数据

{

StuNode *p;

p = StuListHead;

ifstream in("sushea.txt");

if (!in) { cout << "文件sushea.txt中没有学生信息,请先录入学生信息!" << endl; return; }

while (!in.eof())

{

int num; char nam[40]; char cla[40]; char sus[40]; char chu[40];

in >> num >> nam >> cla >> sus >> chu;

StuInsert(num, nam, cla, sus, chu);

 

}

}

 

void Sushe::StuSave()   //保存学生信息

{

StuNode *p;

p = StuListHead->nextstu;

ofstream out("sushea.txt");

if (!out) { cout << "不能打开文件sushea.txt!" << endl; return; }

while (p != NULL)

{

out << p->stu_num << '\t' << p->stu_nam << '\t' << p->stu_cla << '\t' << p->stu_sus << '\t' << p->stu_chu << '\n';

p = p->nextstu;

}

}

 

void Sushe::StuQuit()   //学生信息写入文件

{

char choice;

cout << "是否保存学生信息:?(Y/N)";

cin >> choice;

if (choice == 'y' || choice == 'Y')

{

StuSave();

cout << "学生信息已保存..." << endl;

}

}

 

 

 

void sushe()

{

system("mode con:cols=200 lines=1000");

int pnum;

char pnam[40]; char pcla[40]; char psus[40]; char pchu[40];

StuNode *pfind;

Sushe stu;

while (1)

{

 

system("pause");

system("cls");      //清屏

SuMenu();

int x;

cin >> x;

if (x == 0){

return;

}

switch (x)

{

case 1:

stu.StuRead();

cout << "读入学生宿舍信息表:" << endl;

stu.ShowInfo();

break;

case 2:

stu.CreatSinfo();

cout << "请核对输入学生信息!" << endl;

stu.ShowInfo();

break;

case 3:                           //添加信息

cout << "请输入添加学生宿舍信息:" << endl;

cout << "学号:"; cin >> pnum;

stu.panduan(pnum);

cout << "姓名:"; cin >> pnam;

cout << "班级:"; cin >> pcla;

cout << "宿舍:"; cin >> psus;

cout << "床号:"; cin >> pchu;

stu.StuInsert(pnum, pnam, pcla, psus, pchu);

cout << "更新学生宿舍信息表..." << endl;

stu.ShowInfo();

break;

case 4:

cout << "请输入要删除学生学号:";

cin >> pnum;

stu.StuDelete(pnum);

cout << "更新学生宿舍信息表..." << endl;

stu.ShowInfo();

break;

case 5:

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

cin >> pnum;

pfind = stu.StuFind(pnum);

cout << "查找学生学号:" << pfind->stu_num << " 姓名: " << pfind->stu_nam << " 班级: " << pfind->stu_cla << " 宿舍: " << pfind->stu_sus << " 床号: " << pfind->stu_chu << endl;

break;

case 6:

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

cin >> pnum;

cout << "请重新输入学生宿舍信息!"<<endl;

cout << "姓名:"; cin >> pnam;

cout << "班级:"; cin >> pcla;

cout << "宿舍:"; cin >> psus;

cout << "床号:"; cin >> pchu;

stu.StuModify(pnum, pnam, pcla, psus, pchu);

cout << "更新学生宿舍信息表..." << endl;

stu.ShowInfo();

break;

case 9:

stu.ShowInfo();

break;

case 10:

stu.StuQuit();

break;

}

}

}

 

 

#include "Ruzhu.h"

 

#define MAX_NUM 10000000

#include <String>

#include<ctime>

#include <fstream>

using namespace std;

 

 

struct RuNode{

long ru_num = 0;

char ru_nam[40];

char ru_cla[40];

char ru_mon[40];

char ru_check_in[40];

char ru_check_out[40];

RuNode *nextru;

};

class Ruzhu{

RuNode *RuListHead;

public:

Ruzhu();      //构造函数

~Ruzhu();     //析构函数

void RuCreat();  //创建入住信息

void RuInsert(int num, char* nam, char* cla, char* mon, char* check_in,char* check_out);  //插入入住信息

RuNode *RuFind(int num);   //查找入住信息,传入参数学号

void RuRead();        //从文件读入入住信息

void RuSave();        //保存学生入住信息到文件

void RuQuit();

void RuShow();           //遍历输出学生入住信息

void panduan(int ru_num);

};

void pdweiru(int ru_num)

{

while (ru_num<10000 || ru_num>99999)

{

cout << "你输入的学号不正确,请输入一个五位数的学号" << endl;

cout << "学号:";

cin >> ru_num;

}

 

 

}

 

void Ruzhu::panduan(int ru_num)

{

pdweiru(ru_num);

    RuNode *p;

for (p = RuListHead->nextru; p != NULL; p = p->nextru)

{

while (p->ru_num == ru_num)

{

cout << "学号重复,请重新输入!" << endl;

cout << "学号:";

cin >> ru_num;

}

}

}

 

void RuMenu()

{

time_t t;

time(&t);

cout << "---------------------------------学生入住信息模块-------------------------------" << endl;

cout << "\t\t\t 本地时间:" << ctime(&t);

cout << "--------------------------------------------------------------------------------\n" << endl;

cout << "\t\t 1.读入学生入住信息  " << endl;

cout << "\t\t 2.录入入住信息表格  " << endl;

cout << "\t\t 3.添加新的入住信息  " << endl;

cout << "\t\t 4.查找已有学生信息  " << endl;

cout << "\t\t 5.输出所有学生信息  " << endl;

cout << "\t\t 6.保存现有学生信息 " << endl;

cout << "\t\t 0.返回主菜单   " << endl;

 

cout << "\n\t\n\t\t请选择:";

}

Ruzhu::Ruzhu()   //构造函数

{

RuListHead = new RuNode;

RuListHead->nextru = NULL;

 RuListHead->ru_num = 0;

}

 

Ruzhu::~Ruzhu()       //析构函数

{

RuNode *p;

while (RuListHead)

{

p = RuListHead;

RuListHead = RuListHead->nextru;

delete p;

}

RuListHead = NULL;

}

 

void Ruzhu::RuRead()    //从文件读入数据

{

RuNode *p;

p = RuListHead;

ifstream in("ruzhua.txt");

if (!in) { cout << "文件ruzhua.txt中没有入住信息,请先录入入住信息!" << endl; return; }

while (!in.eof())

{

int num; char nam[40]; char cla[40]; char mon[40]; char check_in[40]; char check_out[40];

in >> num >> nam >> cla >> mon >> check_in >> check_out;

RuInsert(num, nam, cla, mon, check_in, check_out);

 

}

}

void Ruzhu::RuCreat()     //创建学生信息表

{

int n;

RuNode *p, *s;

p = RuListHead;

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

cin >> n;

for (int i = 1; i <= n; i++)

{

s = new RuNode;

cout << "学号:"; cin >> s->ru_num;

panduan(s->ru_num);

cout << "姓名:"; cin >> s->ru_nam;

cout << "班级:"; cin >> s->ru_cla;

cout << "缴费金额:"; cin >> s->ru_mon;

cout << "入住时间:"; cin >> s->ru_check_in;

cout << "退房时间:"; cin >> s->ru_check_out;

s->nextru = p->nextru;

p->nextru = s;

p = p->nextru;

}

if (p == NULL)   //判断学生信息表是否创建成功

{

cout << "创建失败请重新创建!" << endl;

RuCreat();

}

}

 

void Ruzhu::RuInsert(int num, char* nam, char* cla, char* mon, char* check_in, char* check_out)     //插入学生入住信息(头插法)

{

RuNode *s, *p;

s = new RuNode;

s->ru_num = num;

strcpy(s->ru_nam, nam);

strcpy(s->ru_cla, cla);

strcpy(s->ru_mon, mon);

strcpy(s->ru_check_in, check_in);

strcpy(s->ru_check_out, check_out);

p = RuListHead;

s->nextru = p->nextru;

p->nextru = s;

}

 

void Ruzhu::RuShow()      //遍历输出

{

RuNode *p;

cout << "学号" << '\t' << "姓名" << '\t' << "班级" << '\t' << "缴费金额" << '\t' << "入住时间" << '\t'<<"退房时间"<<endl;

for (p = RuListHead->nextru; p != NULL; p = p->nextru)

{

cout << p->ru_num << '\t' << p->ru_nam << '\t' << p->ru_cla << '\t' << p->ru_mon << '\t' << p->ru_check_in<<'\t'<<p->ru_check_out << endl;

}

}

RuNode *Ruzhu::RuFind(int num)

{

RuNode *p;

p = RuListHead->nextru;

while (p->nextru && p->ru_num != num)   //循环终止条件为p->nextru不为空 而且没有找到相应学号的学生

{

p = p->nextru;

}

if (p->ru_num == num)

{

return p;

}

else

{

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

return NULL;

}

}

void Ruzhu::RuSave()   //保存学生信息

{

RuNode *p;

p = RuListHead->nextru;

ofstream out("ruzhua.txt");

if (!out) { cout << "不能打开文件ruzhua.txt!" << endl; return; }

while (p != NULL)

{

out << p->ru_num << '\t' << p->ru_nam << '\t' << p->ru_cla << '\t' << p->ru_mon << '\t' << p->ru_check_in<<'\t'<<p->ru_check_out << '\n';

p = p->nextru;

}

}

 

 

void Ruzhu::RuQuit()   //学生信息写入文件

{

char choice;

cout << "是否保存学生入住信息:?(Y/N)";

cin >> choice;

if (choice == 'y' || choice == 'Y')

{

RuSave();

cout << "学生入住信息已保存..." << endl;

}

}

 

void ruzhu()

{

int pnum;

char pnam[40]; char pcla[40]; char pmon[40]; char pcheck_in[40]; char pcheck_out[40];

RuNode *pfind;

Ruzhu ru;

while (1)

{

 

system("pause");

system("cls");      //清屏

RuMenu();

int x;

cin >> x;

if (x == 0){

return;

}

switch (x)

{

case 1:

ru.RuRead();

cout << "读入学入住信息表:" << endl;

ru.RuShow();

break;

case 2:

ru.RuCreat();

cout << "请核对输入学生信息!" << endl;

ru.RuShow();

break;

case 3:                           //添加信息

cout << "请输入添加学生入住信息:" << endl;

cout << "学号:"; cin >> pnum;

ru.panduan(pnum);

cout << "姓名:"; cin >> pnam;

cout << "班级:"; cin >> pcla;

cout << "缴费金额:"; cin >> pmon;

cout << "入住时间:"; cin >> pcheck_in;

cout << "退房时间:"; cin >> pcheck_out;

ru.RuInsert(pnum, pnam, pcla, pmon, pcheck_in, pcheck_out);

cout << "更新学生入住信息表..." << endl;

ru.RuShow();

break;

case 4:

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

cin >> pnum;

pfind = ru.RuFind(pnum);

cout << "查找学生学号:" << pfind->ru_num << " 姓名: " << pfind->ru_nam << " 班级: " << pfind->ru_cla << " 缴费金额: " << pfind->ru_mon << " 入住时间: " << pfind->ru_check_in << "退房时间:" << pfind->ru_check_out << endl;

break;

case 5:

ru.RuShow();

break;

case 6:

ru.RuQuit();

break;

}

}

}

 

#include"Fuzhu.h"

 

#define MAX_NUM 10000000

#include <String>

#include<ctime>

#include<windows.h>

#include<cstdlib>

#include<iostream>

#include<cstdlib>

#define random(a,b) (rand()%(b-a+1)+a)

using namespace std;

 

void suijishu(int a,int b)

{

srand((unsigned)time(NULL));

for (int i = 0; i<10; i++)

cout << random(a, b) << "    ";

}

 

/*void pdwei(int ru_num)

{

while (ru_num<10000 || ru_num>99999)

{

cout << "你输入的学号不正确,请输入一个五位数的学号" << endl;

cout << "学号:";

cin >> ru_num;

}

}*/

 

int Systemdoor()

{

string username = "hello", password = "nihao";

string name, temp;

int number = 3;

while (1)

{

time_t t;

time(&t);

cout << "---------------------------------欢迎使用学生宿舍管理信息系统-------------------------------" << endl;

cout << "********************************************************************************************" << endl << endl;

cout << "\t\t                                本地时间:" << ctime(&t);

cout << "                用 户 名:";

cin >> name;

cout << "                密    码:";

cin >> temp;

cout << endl;

if (name != username || temp != password)

{

number--;

if (number >0)

{

cout << "          用户名/密码错误!你还有" << number << "次机会" << endl;

}

else

cout << "用户名/密码错误!" << endl, exit(0);

 

}

else

{

cout << "********************密码正确********************" << endl << endl;

for (int i = 0; i <3; i++)

{

Sleep(1000);    /* windows 使用Sleep,参数为毫秒 */

}

system("cls");      //清屏

return 1;

}

}

 

}

 

 

#include"Weisheng.h"

 

#define MAX_NUM 10000000

#include <String>

#include<ctime>

#include <fstream>

using namespace std;

 

 

struct WeiNode{

char wei_score[40];

int wei_n=0;

char wei_sus[40];

    WeiNode *nextwei;

};

class Weisheng{

WeiNode *WeiListHead;

public:

Weisheng();      //构造函数

~Weisheng();     //析构函数

void WeiCreat();  //创建信息

void WeiInsert(int n, char* sus, char* score);  //插入入住信息

WeiNode *WeiFind(char* sus);   //查找入住信息,传入参数宿舍号

void WeiSort(char ch);   //根据 总分排序

void WeiCopy(WeiNode *ptemp, WeiNode *p);

void WeiRead();        //从文件读入信息

void WeiSave();        //保存学信息到文件

void WeiQuit();

void WeiShow();           //遍历输出信息

void panduan(int ru_num);

void Weiin();

};

void WeiMenu()

{

time_t t;

time(&t);

cout << "---------------------------------学生宿舍卫生评比模块-------------------------------" << endl;

cout << "\t\t\t 本地时间:" << ctime(&t);

cout << "--------------------------------------------------------------------------------\n" << endl;

cout << "\t\t 1.读入宿舍卫生信息  " << endl;

cout << "\t\t 2.录入宿舍卫生表格  " << endl;

cout << "\t\t 3.查找宿舍卫生信息  " << endl;

cout << "\t\t 4.输出所有宿舍信息  " << endl;

cout << "\t\t 5.保存现有宿舍信息 " << endl;

cout << "\t\t 0.返回主菜单   " << endl;

 

cout << "\n\t\t请选择:";

}

Weisheng::Weisheng()   //构造函数

{

    WeiListHead = new WeiNode;

WeiListHead->nextwei = NULL;

}

 

Weisheng::~Weisheng()       //析构函数

{

WeiNode *p;

while (WeiListHead)

{

p = WeiListHead;

WeiListHead = WeiListHead->nextwei;

delete p;

}

WeiListHead = NULL;

}

void Weisheng::WeiInsert(int n, char* sus, char* score)     //插入入住信息(头插法)

{

WeiNode *s, *p;

s = new WeiNode;

s->wei_n = n;                 

strcpy(s->wei_sus, sus);

strcpy(s->wei_score, score);

p = WeiListHead;

s->nextwei = p->nextwei;

p->nextwei = s;

}

 

void Weisheng::WeiRead()    //从文件读入数据

{

WeiNode *p;

p = WeiListHead;

ifstream in("weishenga.txt");

if (!in) { cout << "文件weishenga.txt中没有宿舍信息,请先录入宿舍信息!" << endl; return; }

while (!in.eof())

{

int n; char sus[40]; char score[40];

in >> n >> sus >> score;

WeiInsert(n, sus, score);

 

}

}

void Weisheng::WeiCreat()     //创建宿舍卫生信息表

{

int n;

WeiNode *p, *s;

p = WeiListHead;

cout << "请输入学生宿舍卫生条数:";

cin >> n;

for (int i = 1; i <= n; i++)

{

s = new WeiNode;

cout << "宿舍号:"; cin >> s->wei_sus;

//panduan(s->wei_num);

cout << "卫生评分:"; cin >> s->wei_score;

cout << "排名:"; cin >> s->wei_n;

s->nextwei = p->nextwei;

p->nextwei = s;

p = p->nextwei;

}

if (p == NULL)   //判断信息表是否创建成功

{

cout << "创建失败请重新创建!" << endl;

WeiCreat();

}

}

void Weisheng::WeiShow()      //遍历输出

{

WeiNode *p;

cout << "排名" << '\t' << "宿舍" << '\t' << "评分"  << endl;

for (p = WeiListHead->nextwei; p != NULL; p = p->nextwei)

{

cout << p->wei_n << '\t' << p->wei_sus << '\t' << p->wei_score << endl;

}

}

void Weisheng::Weiin()

{

WeiNode *p;

int i = 1;

for (p = WeiListHead->nextwei; p != NULL; p = p->nextwei)

{

p->wei_n = i;

i++;

}

}

WeiNode *Weisheng::WeiFind(char* sus)

{

WeiNode *p;

p = WeiListHead->nextwei;

while (p->nextwei && strcmp(p->wei_sus ,sus)!=0)   //循环终止条件为p->nextru不为空 而且没有找到相应宿舍

{

p = p->nextwei;

}

if (strcmp(p->wei_sus,sus)==0)

{

return p;

}

else

{

cout << "未找到该宿舍信息!" << endl;

return NULL;

}

}

void Weisheng::WeiCopy(WeiNode *ptemp, WeiNode *p)  //拷贝信息(将p的信息拷贝到ptemp中)

{

if (p == NULL)

{

cout << "拷贝目标为空!" << endl;

}

else

{

ptemp->wei_n = p->wei_n;

strcpy(ptemp->wei_sus,p->wei_sus);

strcpy(ptemp->wei_score, p->wei_score);

//ptemp->nextwei = p->nextwei;   //只是信息拷贝,next不能拷贝否则信息丢失

}

}

void Weisheng::WeiSort(char ch)   //根据 总分排序

{

if (ch == '>')

{

for (WeiNode *p = WeiListHead->nextwei; p != NULL; p = p->nextwei)

{

for (WeiNode *q = WeiListHead->nextwei; q != NULL; q = q->nextwei)

{

if (strcmp(p->wei_score ,q->wei_score)>0)

{

WeiNode *ptemp = new WeiNode;

WeiCopy(ptemp, p);

WeiCopy(p, q);

WeiCopy(q, ptemp);

}

}

}

}

else if (ch == '<')

{

for (WeiNode *p = WeiListHead->nextwei; p != NULL; p = p->nextwei)

{

for (WeiNode *q = WeiListHead->nextwei; q != NULL; q = q->nextwei)

{

if (strcmp(p->wei_score, q->wei_score)<0)

{

WeiNode *ptemp = new WeiNode;

WeiCopy(ptemp, p);

WeiCopy(p, q);

WeiCopy(q, ptemp);

}

}

}

}

else

{

cout << "排序条件出错!" << endl;

}

}

 

void Weisheng::WeiSave()   //保存信息

{

WeiNode *p;

p = WeiListHead->nextwei;

ofstream out("weishenga.txt");

if (!out) { cout << "不能打开文件weishenga.txt!" << endl; return; }

while (p != NULL)

{

out << p->wei_n << '\t' << p->wei_sus << '\t' << p->wei_score << '\n';

p = p->nextwei;

}

}

 

 

void Weisheng::WeiQuit()   //信息写入文件

{

char choice;

cout << "是否保存宿舍卫生信息:?(Y/N)";

cin >> choice;

if (choice == 'y' || choice == 'Y')

{

WeiSave();

cout << "宿舍卫生信息已保存..." << endl;

}

}

void weisheng()

{

char psus[40];

WeiNode *pfind;

Weisheng wei;

while (1)

{

 

system("pause");

system("cls");      //清屏

WeiMenu();

int x;

cin >> x;

if (x == 0){

return;

}

switch (x)

{

case 1:

wei.WeiRead();

cout << "读入宿舍卫生评分信息表:" << endl;

wei.WeiShow();

break;

case 2:

wei.WeiCreat();

cout << "请核对输入评分信息!" << endl;

wei.WeiShow();

break;

case 3:

cout << "请输入要查找宿舍:";

cin >> psus;

pfind = wei.WeiFind(psus);

cout << "查找宿舍卫生情况:" << endl;

cout<<"宿舍排名:"<<pfind->wei_n << " 宿舍号: " << pfind->wei_sus << " 评分: " << pfind->wei_score << endl;

break;

case 4:

cout << "宿舍卫生排名升序排序请按1!倒序排序请按2!" << endl;

int p;

cin >> p;

if (p == 1)

{

wei.WeiSort('<');

wei.Weiin();

wei.WeiShow();

}

else if (p == 2)

{

wei.WeiSort('>');

wei.WeiShow();

}

else

{

cout << "输入指令错误!" << endl;

}

break;

case 5:

wei.WeiQuit();

break;

}

}

}

 

 

#include"Shoufei.h"

 

#define MAX_NUM 10000000

#include <windows.h>

#include <String>

#include<ctime>

#include <fstream>

using namespace std;

 

 

struct ShouNode{

int shou_du = 0;

int shou_fei;

char shou_sus[40];

ShouNode *nextshou;

};

class Shoufei{

ShouNode *ShouListHead;

public:

Shoufei();      //构造函数

~Shoufei();     //析构函数

void ShouCreat();  //创建宿舍收费表信息

void ShouInsert(char* sus, int du,int fei);  //插入宿舍收费信息信息

ShouNode *ShouFind(char* sus);   //查找信息,传入参数学号

void ShouRead();        //从文件读入宿舍收费信息

void ShouSave();        //保存信息到文件

void ShouQuit();

void ShouShow();           //遍历输出宿舍收费信息

 

};

void ShouMenu()

{

time_t t;

time(&t);

cout << "---------------------------------宿舍水电费模块-------------------------------" << endl;

cout << "\t\t\t 本地时间:" << ctime(&t);

cout << "--------------------------------------------------------------------------------\n" << endl;

cout << "\t\t 1.读入宿舍水电信息  " << endl;

cout << "\t\t 2.录入宿舍水电表格  " << endl;

cout << "\t\t 3.查找已有宿舍信息  " << endl;

cout << "\t\t 4.输出所有收费信息  " << endl;

cout << "\t\t 5.保存宿舍收费信息 " << endl;

cout << "\t\t 0.返回主菜单   " << endl;

 

cout << "\n\t\n\t\t请选择:";

}

Shoufei::Shoufei()   //构造函数

{

ShouListHead = new ShouNode;

ShouListHead->nextshou = NULL;

}

 

Shoufei::~Shoufei()       //析构函数

{

ShouNode *p;

while (ShouListHead)

{

p = ShouListHead;

ShouListHead = ShouListHead->nextshou;

delete p;

}

ShouListHead = NULL;

}

 

void Shoufei::ShouRead()    //从文件读入数据

{

ShouNode *p;

p = ShouListHead;

ifstream in("shoufeia.txt");

if (!in) { cout << "文件shoufeia.txt中没有入住信息,请先录入入住信息!" << endl; return; }

while (!in.eof())

{

int du,fei; char sus[40];

in >> sus >> du >> fei;

ShouInsert(sus,du,fei);

 

}

}

int standard(int du){

int fei=100;

if (du > 200)

return (100 + (du - 200) * 3);

else

return fei;

}

void Shoufei::ShouCreat()     //创建信息表

{

int n;

ShouNode *p, *s;

p = ShouListHead;

cout << "请输入录入宿舍条数:";

cin >> n;

for (int i = 1; i <= n; i++)

{

s = new ShouNode;

cout << "宿舍:"; cin >> s->shou_sus;

cout << "水电使用度:"; cin >> s->shou_du;

s->shou_fei = standard(s->shou_du);

s->nextshou = p->nextshou;

p->nextshou = s;

p = p->nextshou;

}

if (p == NULL)   //判断信息表是否创建成功

{

cout << "创建失败请重新创建!" << endl;

ShouCreat();

}

}

 

void Shoufei::ShouInsert(char* sus, int du, int fei)   //插入宿舍收费信息(头插法)

{

ShouNode *s, *p;

s = new ShouNode;

s->shou_du = du;

s->shou_fei = fei;

strcpy(s->shou_sus, sus);

p = ShouListHead;

s->nextshou = p->nextshou;

p->nextshou = s;

}

 

ShouNode *Shoufei::ShouFind(char* sus)

{

ShouNode *p;

p = ShouListHead->nextshou;

while (p->nextshou && strcmp(p->shou_sus, sus) != 0)   //循环终止条件为p->nextru不为空 而且没有找到宿舍

{

p = p->nextshou;

}

if (strcmp(p->shou_sus, sus) == 0)

{

return p;

}

else

{

cout << "未找到该宿舍信息!" << endl;

return NULL;

}

}

void Shoufei::ShouShow()      //遍历输出

{

ShouNode *p;

HANDLE handle;

handle = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);//设置控制台字体颜色为红色

//printf("这是红色\n");

cout << "提示!规定水电量在200度,收费100元,若超出则按超出部分每平方3元收费" << endl;

//SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY);//灰色

SetConsoleTextAttribute(handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);//恢复默认的灰色

//printf("这是灰色\n");

cout << "宿舍" << '\t' << "水电度数" << '\t' << "水电费用" << endl;

for (p = ShouListHead->nextshou; p != NULL; p = p->nextshou)

{

cout << p->shou_sus << '\t'<<"     " << p->shou_du << '\t' << p->shou_fei<< endl;

}

}

void Shoufei::ShouSave()   //保存信息

{

ShouNode *p;

p = ShouListHead->nextshou;

ofstream out("shoufeia.txt");

if (!out) { cout << "不能打开文件shoufeia.txt!" << endl; return; }

while (p != NULL)

{

out << p->shou_sus << '\t' << p->shou_du << '\t' << p->shou_fei << endl;

p = p->nextshou;

}

}

 

 

void Shoufei::ShouQuit()   //信息写入文件

{

char choice;

cout << "是否保存宿舍水电费收费信息:?(Y/N)";

cin >> choice;

if (choice == 'y' || choice == 'Y')

{

ShouSave();

cout << "宿舍水电收费信息已保存..." << endl;

}

}

 

void shoufei()

{

char psus[40];

ShouNode *pfind;

Shoufei sf;

while (1)

{

 

system("pause");

system("cls");      //清屏

ShouMenu();

int x;

cin >> x;

if (x == 0){

return;

}

switch (x)

{

case 1:

sf.ShouRead();

cout << "读入宿舍收费表:" << endl;

sf.ShouShow();

break;

case 2:

sf.ShouCreat();

cout << "请核对输入宿舍收费信息!" << endl<<endl;

sf.ShouShow();

break;

case 3:

cout << "请输入要查找宿舍:";

cin >> psus;

pfind = sf.ShouFind(psus);

cout << "要查找的宿舍:" << pfind->shou_sus << " 水电度数: " << pfind->shou_du << " 水电收费: " << pfind->shou_fei << endl;

break;

case 4:

sf.ShouShow();

break;

case 5:

sf.ShouQuit();

break;

}

}

}

 

 

#include"baoxiu.h"

 

#define MAX_NUM 10000000

#include <String>

#include<ctime>

#include <fstream>

using namespace std;

struct BaoNode{

char bao_sus[40];

char bao_pro[40];

char bao_tim[40];

char bao_zhu[40];

BaoNode *nextbao;

};

 

class Baoxiu{

     BaoNode *BaoListHead;

public:

Baoxiu();      //构造函数

~Baoxiu();     //析构函数

void BaoCreat();  //创建信息

void BaoInsert(char* sus, char* pro, char* tim, char* zhu);  //插入信息

BaoNode *BaoFind(char *sus);   //查找信息,传入参数学号

void BaoRead();        //从文件读入信息

void BaoSave();        //保存信息到文件

void BaoQuit();

void BaoShow();           //遍历输出信息

};

void BaoMenu()

{

time_t t;

time(&t);

cout << "---------------------------------宿舍房屋报修模块-------------------------------" << endl;

cout << "\t\t\t 本地时间:" << ctime(&t);

cout << "--------------------------------------------------------------------------------\n" << endl;

cout << "\t\t 1.读入宿舍报修信息  " << endl;

cout << "\t\t 2.录入宿舍报修信息  " << endl;

cout << "\t\t 3.查找已有宿舍信息  " << endl;

cout << "\t\t 4.输出所有宿舍信息  " << endl;

cout << "\t\t 5.保存宿舍报修信息 " << endl;

cout << "\t\t 0.返回信息主菜单   " << endl;

cout << "\n\t\t请选择:";

}

 

Baoxiu::Baoxiu()   //构造函数

{

BaoListHead = new BaoNode;

BaoListHead->nextbao = NULL;

}

 

Baoxiu::~Baoxiu()       //析构函数

{

BaoNode *p;

while (BaoListHead)

{

p = BaoListHead;

BaoListHead = BaoListHead->nextbao;

delete p;

}

BaoListHead = NULL;

}

 

void Baoxiu::BaoCreat()     //创建学生信息表

{

int n;

BaoNode *p, *s;

p = BaoListHead;

cout << "请输入录入宿舍条数:";

cin >> n;

for (int i = 1; i <= n; i++)

{

s = new BaoNode;

cout << "宿舍:"; cin >> s->bao_sus;

cout << "报修项目:"; cin >> s->bao_pro;

cout << "预约时间:"; cin >> s->bao_tim;

cout << "维修状态:"; cin >> s->bao_zhu;

s->nextbao = p->nextbao;

p->nextbao = s;

p = p->nextbao;

}

if (p == NULL)   //判断维修表是否创建成功

{

cout << "创建失败请重新创建!" << endl;

BaoCreat();

}

}

 

void Baoxiu::BaoShow()      //遍历输出

{

BaoNode *p;

cout << "宿舍" << '\t' << "报修项目" << '\t' << "预约时间" << '\t' << "维修状态" << endl;

for (p = BaoListHead->nextbao; p != NULL; p = p->nextbao)

{

cout << p->bao_sus << '\t' << p->bao_pro << '\t' << p->bao_tim << '\t' << p->bao_zhu << endl;

}

}

 

 

void Baoxiu::BaoInsert(char* sus, char* pro, char* tim, char* zhu)     //插入信息(头插法)

{

BaoNode *s, *p;

s = new BaoNode;

strcpy(s->bao_sus, sus);

strcpy(s->bao_pro, pro);

strcpy(s->bao_tim, tim);

strcpy(s->bao_zhu, zhu);

p = BaoListHead;

s->nextbao = p->nextbao;

p->nextbao = s;

}

 

 

BaoNode *Baoxiu::BaoFind(char* sus)

{

BaoNode *p;

p = BaoListHead->nextbao;

while (p->nextbao && strcmp(p->bao_sus, sus) != 0)   //循环终止条件为p->nextru不为空 而且没有找到宿舍

{

p = p->nextbao;

}

if (strcmp(p->bao_sus, sus) == 0)

{

return p;

}

else

{

cout << "未找到该宿舍维修信息!" << endl;

return NULL;

}

}

 

void Baoxiu::BaoRead()    //从文件读入数据

{

BaoNode *p;

p = BaoListHead;

ifstream in("baoxiua.txt");

if (!in) { cout << "文件baoxiua.txt中没有报修信息,请先录入报修信息!" << endl; return; }

while (!in.eof())

{

char sus[40]; char pro[40]; char tim[40]; char zhu[40];

in >> sus >> pro >> tim >> zhu;

BaoInsert(sus, pro, tim, zhu);

 

}

}

 

void Baoxiu::BaoSave()   //保存信息

{

BaoNode *p;

p = BaoListHead->nextbao;

ofstream out("baoxiua.txt");

if (!out) { cout << "不能打开文件baoxiua.txt!" << endl; return; }

while (p != NULL)

{

out << p->bao_sus << '\t' << p->bao_pro << '\t' << p->bao_tim << '\t' << p->bao_zhu << endl;

p = p->nextbao;

}

}

 

void Baoxiu::BaoQuit()   //信息写入文件

{

char choice;

cout << "是否保存报修信息:?(Y/N)";

cin >> choice;

if (choice == 'y' || choice == 'Y')

{

BaoSave();

cout << "报修信息已保存..." << endl;

}

}

void baoxiu()

{

char psus[40];

BaoNode *pfind;

Baoxiu bx;

while (1)

{

 

system("pause");

system("cls");   

    BaoMenu();

int x;

cin >> x;

if (x == 0){

return;

}

switch (x)

{

case 1:

bx.BaoRead();

cout << "读入宿舍报修表:" << endl;

bx.BaoShow();

break;

case 2:

bx.BaoCreat();

cout << "请核对输入宿舍报修信息!" << endl << endl;

bx.BaoShow();

break;

case 3:

cout << "请输入要查找宿舍:";

cin >> psus;

pfind = bx.BaoFind(psus);

    cout << "要查找的宿舍:" << pfind->bao_sus << "  报修项目:" << pfind->bao_pro << "  预约时间:" << pfind->bao_tim<<" 维修状态:"<<pfind->bao_zhu<< endl;

break;

case 4:

bx.BaoShow();

break;

case 5:

bx.BaoQuit();

break;

}

}

}

 

#include"Dengji.h"

 

#define MAX_NUM 10000000

#include <String>

#include<ctime>

#include <fstream>

using namespace std;

 

struct DenNode{

char den_nam[40];

char den_tel[40];

char den_op[40];

char den_intime[40];

char den_outtime[40];

DenNode *nextden;

};

 

class Dengji{

DenNode *DenListHead;

public:

Dengji();      //构造函数

~Dengji();     //析构函数

void DenInsert(char* nam,char* op,char* tel,char* intime,char* outtime);  //插入信息

DenNode *DenFind(char *nam);   //查找信息,传入参数学号

void DenRead();        //从文件读入信息

void DenSave();        //保存信息到文件

void DenQuit();

void DenShow();           //遍历输出信息

};

void DenMenu()

{

time_t t;

time(&t);

cout << "---------------------------------宿舍房屋报修模块-------------------------------" << endl;

cout << "\t\t\t 本地时间:" << ctime(&t);

cout << "--------------------------------------------------------------------------------\n" << endl;

cout << "\t\t 1.读入人员登记信息  " << endl;

cout << "\t\t 2.进入登记信息  " << endl;

cout << "\t\t 3.离开登记信息  " << endl;

cout << "\t\t 4.查找外来登记信息  " << endl;

cout << "\t\t 5.输出所有登记信息  " << endl;

cout << "\t\t 6.保存登记信息 " << endl;

cout << "\t\t 0.返回信息主菜单   " << endl;

cout << "\n\t\t请选择:";

}

 

Dengji::Dengji()   //构造函数

{

DenListHead = new DenNode;

DenListHead->nextden = NULL;

}

 

Dengji::~Dengji()       //析构函数

{

DenNode *p;

while (DenListHead)

{

p = DenListHead;

DenListHead = DenListHead->nextden;

delete p;

}

DenListHead = NULL;

}

 

 

void Dengji::DenShow()      //遍历输出

{

DenNode *p;

cout << "来访人姓名" << '\t' << "来访理由" << '\t' << "联系方式" << '\t' << "来访时间"<<'\t'<<"离开时间" << endl;

for (p = DenListHead->nextden; p != NULL; p = p->nextden)

{

cout << p->den_nam << '\t' << p->den_op << '\t' << p->den_tel << '\t' << p->den_intime<<'\t'<<p->den_outtime << endl;

}

}

 

 

void Dengji::DenInsert(char* nam, char* op, char* tel,char* intime,char* outtime)     //插入信息(头插法)

{

DenNode *s, *p;

s = new DenNode;

strcpy(s->den_nam, nam);

strcpy(s->den_op, op);

strcpy(s->den_tel, tel);

strcpy(s->den_intime, intime);

strcpy(s->den_outtime, outtime);

p = DenListHead;

s->nextden = p->nextden;

p->nextden = s;

}

 

 

DenNode *Dengji::DenFind(char* nam)

{

DenNode *p;

p = DenListHead->nextden;

while (p->nextden && strcmp(p->den_nam, nam) != 0)   //循环终止条件为p->nextru不为空 而且没有找到宿舍

{

p = p->nextden;

}

if (strcmp(p->den_nam, nam) == 0)

{

return p;

}

else

{

cout << "未找到外来登记信息!" << endl;

return NULL;

}

}

 

void Dengji::DenRead()    //从文件读入数据

{

DenNode *p;

p = DenListHead;

ifstream in("dengjia.txt");

if (!in) { cout << "文件dengjia.txt中没有报修信息,请先录入报修信息!" << endl; return; }

while (!in.eof())

{

char nam[40]; char op[40]; char tel[40]; char intime[40]; char outtime[40];

in >> nam >> op >> tel >> intime >> outtime;

DenInsert(nam, op, tel,intime,outtime);

 

}

}

 

void Dengji::DenSave()   //保存信息

{

DenNode *p;

p = DenListHead->nextden;

ofstream out("dengjia.txt");

if (!out) { cout << "不能打开文件dengjia.txt!" << endl; return; }

while (p != NULL)

{

out << p->den_nam << '\t' << p->den_op << '\t' << p->den_tel << '\t' << p->den_intime << '\t' << p->den_outtime << endl;

p = p->nextden;

}

}

 

void Dengji::DenQuit()   //信息写入文件

{

char choice;

cout << "是否保存登记信息:?(Y/N)";

cin >> choice;

if (choice == 'y' || choice == 'Y')

{

DenSave();

cout << "登记信息已保存..." << endl;

}

}

void dengji()

{

char nam[40], op[40], tel[40], intime[40];

char outtime[40]="未离开";

DenNode *pfind;

Dengji dj;

while (1)

{

system("pause");

system("cls");

DenMenu();

int x;

cin >> x;

if (x == 0){

return;

}

switch (x)

{

case 1:

dj.DenRead();

cout << "读入宿舍外来人员登记表:" << endl;

dj.DenShow();

break;

case 2:

time_t a;

time(&a);

cout << "来访人姓名:"; cin >> nam;

cout << "来访理由:"; cin >> op;

cout << "联系方式:"; cin >> tel;

strcpy(intime, ctime(&a));

dj.DenInsert(nam, op, tel, intime, outtime);

cout << "请核对输入外来人员登记信息!" <<endl;

dj.DenShow();

break;

case 3:

time_t b;

time(&b);

cout << "来访人姓名:"; cin >> nam;

pfind = dj.DenFind(nam);

strcpy(pfind->den_outtime, ctime(&b));

cout << "离开时间已登记!" << ctime(&b) << endl;

break;

case 4:

cout << "请输入要查找来访人姓名:";

cin >> nam;

pfind = dj.DenFind(nam);

cout << "要查找的人员:" << pfind->den_nam << "  来访理由:" << pfind->den_op << "  联系方式:" << pfind->den_tel << " 来访时间:" << pfind->den_intime<<"  离开时间:" <<pfind->den_outtime<< endl;

break;

case 5:

dj.DenShow();

break;

case 6:

dj.DenQuit();

break;

}

}

}

 

 

#include"Chaqin.h"

 

#define MAX_NUM 10000000

#include <String>

#include<ctime>

#include <fstream>

using namespace std;

void chaqin()

{

int n;

cout << "请输入楼层数:"; cin >> n;

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

int a, b;

cout << "请输入" << i << "楼层查寝宿舍区间:";

cin >> a >> b;

cout << i << "楼查寝宿舍" << endl;

suijishu(a, b);

cout << endl << endl;

}

}

 

 

2、主函数:

 

 

#include<iostream>

#include<windows.h>

#include "Sushe.h"

#include "Ruzhu.h"

#include"Fuzhu.h"

#include"Weisheng.h"

#include"Shoufei.h"

#include"baoxiu.h"

#include"Dengji.h"

#include"Chaqin.h"

#include<cstdlib>

 

using namespace std;

 

int main()

{

Systemdoor();

cout << "   ********************************************************************************************************************" << endl;

cout << "   ********************************************************************************************************************" << endl;

cout << "   ********************************************************************************************************************" << endl;

cout << "   ********************************************************************************************************************" << endl;

cout << "   *******************                                                                              *******************" << endl;

cout << "   *******************                                                                              *******************" << endl;

cout << "   *******************                       欢迎进入学生宿舍管理信息管理系统                       *******************" << endl;

cout << "   *******************                                                                              ******************" << endl;

cout << "   *******************                                                                              *******************" << endl;

cout << "   ********************************************************************************************************************" << endl;

cout << "   ********************************************************************************************************************" << endl;

cout << "   ********************************************************************************************************************" << endl;

cout << "   ********************************************************************************************************************" << endl;

while(1){

system("pause");

system("cls");      //清屏

time_t t;

time(&t);

cout << "---------------------------------学生宿舍管理信息系统主菜单-------------------------------" << endl;

cout << "\t\t          本地时间:" << ctime(&t);

cout << "------------------------------------------------------------------------------------------\n" << endl;

cout << "\t\t 0.安全退出系统   " << endl;

cout << "\t\t 1.宿舍信息模块   " << endl;

cout << "\t\t 2.学生入住模块  " << endl;

cout << "\t\t 3.卫生检查模块 " << endl;

cout << "\t\t 4.水电收费模块  " << endl;

cout << "\t\t 5.房屋报修模块  " << endl;

cout << "\t\t 6.外来人员登记  " << endl;

cout << "\t\t 7.宿舍随机查寝 " << endl;

cout << "\n\n\t请输入选择:";

int x;

cin >> x;

if (x == 0)

return 0;

switch (x)

{

case 1:

sushe();

break;

case 2:

ruzhu();

break;

case 3:

weisheng();

break;

case 4:

shoufei();

break;

case 5:

baoxiu();

break;

case 6:

dengji();

break;

case 7:

chaqin();

break;

}

}

cout << "退出成功!";

return 0;

}

 

 

 

 

 

五、程序运行的测试与分析

 

 

 

 

 

六、结论与心得

经过两个星期左右的时间终于把课程设计做完啦,说实话心里终于可以放松。回头想想这两个星期的经历,感觉多走了很多弯路,掉的坑真是不应该!就比如说刚开始时的参数传递,如何将输入的汉字传入到类内函数中,就直接用字符数组最后用类内函数的字符指针参数进行引用输入的汉字即可,这么简单的问题我想了很久很久,查阅很多资料,最后还是看别人的例题才明白怎么使用,感觉以前的面向对象白学啦!

在开始毫无头绪,不知道自己要怎么把这个宿舍管理系统做出来时,我想过用数据库,用java,百度发现有用c#写的,就是没有想到用C++写,就不知道C++还能做出来界面,感觉以前对C++面向对象编程只处于在输出hello Word,单个页面上面!真是悔恨对C++了解不深入。在那样一个情况下,课程设计又必须是C++写,怎么办?百度下把,结果令人失望的是没有这样的,我只能找了一个学生成绩系统的例子作参考,认真的看怎么写的程序,就这样把自己的课程设计做出来,从中学到很多知识,进一步了解什么叫编程,什么叫系统项目。

从头到尾审视写的函数,感觉C++编程太厉害,比较以前在学C++的过程中又进一步认识到面向对象,以及系统的编程。仔细想想,自己写的程序不过皮毛,只用到一个链表存储和文本读写,其他高大上的编程还没有接触到,所以以后要更努力的学习,深入思考,多接触系统的项目!

七、参考资料

查阅资料:

[1]谭浩强,c++面向对象程序设计,北京:清华大学出版社,2014

  [2]Stephen Prata , C++ Primer Plus中文版,北京:人民邮电出版,2012

 

  • 66
    点赞
  • 395
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
很抱歉,我不能为您提供完整的代码。但是,我可以为您提供一个简单的宿舍管理系统的框架,您可以根据自己的需求进行修改和完善。 ```c++ #include <iostream> #include <string> #include <vector> using namespace std; // 学生类 class Student { private: string name; int id; string dormitory; public: Student(string n, int i, string d) { name = n; id = i; dormitory = d; } string getName() { return name; } int getId() { return id; } string getDormitory() { return dormitory; } }; // 宿舍类 class Dormitory { private: string name; int capacity; vector<Student*> students; // 存储学生的指针 public: Dormitory(string n, int c) { name = n; capacity = c; } string getName() { return name; } int getCapacity() { return capacity; } int getOccupied() { return students.size(); } bool addStudent(Student* s) { if (students.size() < capacity) { students.push_back(s); return true; } return false; } void removeStudent(Student* s) { for (int i = 0; i < students.size(); i++) { if (students[i]->getId() == s->getId()) { students.erase(students.begin() + i); break; } } } void printStudents() { for (int i = 0; i < students.size(); i++) { cout << students[i]->getName() << " " << students[i]->getId() << endl; } } }; // 宿舍楼类 class DormitoryBuilding { private: vector<Dormitory*> dormitories; // 存储宿舍的指针 public: bool addDormitory(Dormitory* d) { dormitories.push_back(d); return true; } Dormitory* findDormitory(string name) { for (int i = 0; i < dormitories.size(); i++) { if (dormitories[i]->getName() == name) { return dormitories[i]; } } return NULL; } }; int main() { // 创建宿舍楼 DormitoryBuilding* dormitoryBuilding = new DormitoryBuilding(); // 创建宿舍 Dormitory* dormitory1 = new Dormitory("Dormitory 1", 4); dormitoryBuilding->addDormitory(dormitory1); Dormitory* dormitory2 = new Dormitory("Dormitory 2", 3); dormitoryBuilding->addDormitory(dormitory2); Dormitory* dormitory3 = new Dormitory("Dormitory 3", 2); dormitoryBuilding->addDormitory(dormitory3); // 创建学生 Student* student1 = new Student("Tom", 1001, ""); dormitory1->addStudent(student1); Student* student2 = new Student("Jerry", 1002, ""); dormitory1->addStudent(student2); Student* student3 = new Student("Mary", 1003, ""); dormitory1->addStudent(student3); Student* student4 = new Student("John", 1004, ""); dormitory1->addStudent(student4); Student* student5 = new Student("Bob", 1005, ""); dormitory2->addStudent(student5); Student* student6 = new Student("Alice", 1006, ""); dormitory2->addStudent(student6); Student* student7 = new Student("David", 1007, ""); dormitory2->addStudent(student7); Student* student8 = new Student("Lily", 1008, ""); dormitory3->addStudent(student8); Student* student9 = new Student("Kate", 1009, ""); dormitory3->addStudent(student9); // 输出宿舍信息 Dormitory* dormitory = dormitoryBuilding->findDormitory("Dormitory 1"); cout << dormitory->getName() << " capacity: " << dormitory->getCapacity() << " occupied: " << dormitory->getOccupied() << endl; dormitory->printStudents(); return 0; } ``` 在这个简单的框架中,我们定义了三个类:学生类、宿舍类和宿舍楼类。学生类包含学生的姓名、学号和宿舍信息;宿舍类包含宿舍的名称、容量、学生列表等信息;宿舍楼类包含宿舍列表等信息。我们在 `main()` 函数中创建了宿舍楼、宿舍和学生,并将学生添加到相应的宿舍中,最后输出宿舍信息。 注意,这只是一个简单的框架,您需要根据自己的需求进行修改和完善。
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值