文章
37
粉丝
168
获赞
13
访问
285.2k
#include <bits/stdc++.h>
using namespace std;
struct tt{
string id,name;
int grade;
};
bool cmp1(tt a, tt b){
a.id<b.id;
}
bool cmp2(tt a, tt b){
return a.name<b.name;
}
bool cmp3(tt a, tt b){
return a.grade<b.grade;
}
int main()
{
int N,C;
while(cin >>N>>C){
struct tt t[N];
for(int i=0; i<N; i++){
cin>>t[i].id>>t[i].name>>t[i].grade;
}
switch(C){
case 1:
sort(t,t+N,cmp1);
break;
case 2:
sort(t,t+N,cmp2);
break;
case 3:
sort(t,t+N,cmp3);
break;
}
cout<<"Case:"<<endl;
for(int i=0;i<N; i++){
cout<<t[i].id<<' '<<t[i].name<<' '<<t[i].grade<<endl;
}
}
}
登录后发布评论
暂无评论,来抢沙发