c语言宿舍管理查询软件,宿舍管理查询软件--数据结构,c语言

本文档描述了一个学生宿舍管理系统的功能模块,包括信息录入、保存、排序、查询和打印。系统采用结构体存储学生信息,支持按学号、宿舍号和姓名进行排序和查询。此外,还提供了主菜单供用户交互,实现对宿舍信息的增删改查操作。
摘要由CSDN通过智能技术生成

8abb8f0d8abfba9ee6e96f1e678c9790.png

四、功能模块说明

输入学生宿舍信息模块:完成宿舍信息的录入,可以选择从平台手动输入,也可以选择从指定文件中读取。

保存学生宿舍信息模块,完成宿舍信息的保存。

排序学生宿舍信息模块,完成按关键字排序的功能,可以选择按宿舍号、学号或姓名进行排序。

查询学生宿舍信息模块,完成按关键字查询的功能,可以选择按宿舍号、学号或姓名进行查询。

浏览学生宿舍信息模块,完成对已经输入的信息的打印浏览,如果没有向系统输入数据,将提醒无文件数据存在,请进行输入。

最后退出系统。

五、实验过程

#include#include#include#include#includeusing namespace std;

#define Max 100

int total;

struct edg

//构造结构体,创建学生信息的结构体数组,其中的信息包含名字,宿舍房号以及学号 。

{

string name;

int number;

int domenumber;

}student[Max];

edg s[Max];

void menu() //主菜单的函数包含3个功能(新建,排序,查询,打印)

{

cout<>total;

if(ofs)

{

for(i=1;i<=total;i++) //为每个同学输入信息

{

cout<>a;

student[i].name=a;

ofs<>b;

student[i].number=b;

ofs<>c;

student[i].domenumber=c;

ofs

return -1;

int mid=(left+right)/2;

if(student[mid].number==key) //刚好要查找的对象key在mid这个位置,查找成功

return mid;

else if(student[mid].number>choice;

break;

}

if(choice[0]=='1') //进行以学号为关键字的排序

{

for(i=1;i<=total;i++) //用冒泡排序法进行排序

for(j=1;j=student[j+1].number)

{

edg temp;

temp=student[j];

student[j]=student[j+1];

student[j+1]=temp;

}

cout<=student[j+1].domenumber)

{

edg temp;

temp=student[j];

student[j]=student[j+1];

student[j+1]=temp;

}

cout<=student[j+1].name)

{

edg temp;

temp=student[j];

student[j]=student[j+1];

student[j+1]=temp;

}

cout<>choice;

break;

}

if(choice[0]=='1')

{

cout<>a;

for(i=1;i<=total;i++)

{

//c_str返回当前的字符串的首地址,c_str()把string对象转换成c中的字符串样式

if(strcmp(student[i].name.c_str(),a.c_str())==0) s[i]=student[i];

break;

}

if(i!=total+1)

{

cout<>choice1;

if(choice1[0]=='s')

{

cout<>choice1;

if(choice1[0]=='s')

{

cout<>b;

//int len=b.size(); //b.length为字符串b的长度,b.size()为字符串b的元素个数

if(bin_search(1,total,b)!=-1) //b为关键字 使用二分的方法来找到位置,若return结果为-1则表示学号没有录入系统中

{

s[i]=student[bin_search(1,total,b)];

cout<>choice1;

if(choice1[0]=='s')

{

cout<>choice1;

if(choice1[0]=='s')

{

cout<>c;

for(i=1;i<=total;i++)

{

if(c==student[i].domenumber)

{

s[i]=student[i];

cout<>choice1;

if(choice1[0]=='s')

{

cout<>choice;

if(choice[0]=='1')

{

build();

cout<>choice;

if(choice[0]=='s')

{

system("cls");

menu();

}

else

break;

}

else if(choice[0]=='2')

{

sortmenu();

cout<>choice;

if(choice[0]=='s')

{

system("cls");

menu();

}

else

break;

}

else if(choice[0]=='3')

{

query();

cout<>choice;

if(choice[0]=='s')

{

system("cls");

menu();

}

else

break;

}

else if(choice[0]=='4')

{

print();

cout<>choice;

if(choice[0]=='s')

{

system("cls");

menu();

}

else

break;

}

else

{

cout<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值