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<
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的c语言宿舍管理查询软件,宿舍管理查询软件--数据结构,c语言的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c语言windows api编程,win
- 下一篇: 华为宣布与美团达成合作 正式启动鸿蒙原生