student[j+1]=temp;
}
cout<<“姓名\t\t学号\t\t宿舍号”<<endl;
for(i=1;i<=Total;i++)
{
cout<<student[i].name<<"\t\t"<<student[i].number<<"\t\t"<<student[i].domenumber<<endl;
}
cout<<endl;
}
if(choice[0]==‘3’) //以按学生姓名的关键字进行排序
{
for(i=1;i<=Total;i++)
for(j=1;j<Total-i+1; j++) //用冒泡排序法进行排序
if(strcmp(student[j].name.c_str(),student[j+1].name.c_str())>=0)
{
edg temp=student[j];
student[j]=student[j+1];
student[j+1]=temp;
}
cout<<“姓名\t\t学号\t\t宿舍号”<<endl;
for(i=1;i<=Total;i++)
{
cout<<student[i].name<<"\t\t"<<student[i].number<<"\t\t"<<student[i].domenumber<<endl;
}
cout<<endl;
}
return ;
}
void query() //查询函数
{
string choice;
int m,i,j;
string a,choice1;
string b,c;
system(“cls”);
cout<<“请输入查找的方式(1:按名字查找,2:按学号查找,3:按房号查找):”<<endl; //三个关键字进行查找
while(1)
{
while(1) //对输入的信息进行容错处理,防止出现输入字母的情况
{
m=0;
cin>>choice;
if(strlen(choice.c_str())>1)
{
m=1;
cout<<“输入错误,请重新输入”;
}
if(choice[0]>‘3’||choice[0]<‘1’)
{
cout<<“输入数字没有此选项请重新输入”<<endl;
m=1;
}
if(m==0)
break;
}
if(choice[0]==‘1’) //以 名字为关键字进行查询
{
cout<<“输入你想要查找学生的名字:”;
cin>>a;
for(i=1;i<=Total;i++)
{
if(strcmp(student[i].name.c_str(),a.c_str())==0) //使用strcmp及.c_str进行比较
break;
}
if(i!=Total+1)
{
cout<<“目标学生的学号为:”<<student[i].number<<" 宿舍号为"<<student[i].domenumber<<endl;
cout<<“是否继续进行此操作(是为y,不是为n):”;
cin>>choice1;
if(choice1[0]=