宿舍信息管理系统,kotlin命令行输入值

这是一个使用Kotlin编写的宿舍信息管理系统,包括增删查改宿舍信息,通过命令行交互,支持按姓名、学号和宿舍号进行排序和查询。
摘要由CSDN通过智能技术生成

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]=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值