2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > c语言宿舍管理查询软件 宿舍管理查询软件--数据结构 c语言

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

时间:2021-03-19 10:36:06

相关推荐

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

四、功能模块说明

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

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

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

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

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

最后退出系统。

五、实验过程

#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<

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。