水题,还是字典排序,没神马好说的;#include<iostream>#include<stdlib.h>#include<stdio.h>#include<string>#include<cstring>#include<vector>#include<algorithm>using namespace std;using std::vector;const int maxn=100010;struct people{ int age; char name[9]; int worth;}mem[maxn];bool cmp(people a,people b){ if(a.worth==b.worth){ if(a.age==b.age){ return strcmp(a.name,b.name)<0; }else{ return a.age<b.age; } }else{ return a.worth>b.worth; }}int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=0;i<n;i++){ scanf("%s %d %d",mem[i].name,&mem[i].age,&mem[i].worth); } sort(mem,mem+n,cmp); for(int i=0;i<m;i++){ printf(“Case #%d:\n”,i+1); int _max,_min,M; bool flag=false; scanf("%d%d%d",&M,&_min,&_max); for(int j=0;j<n&&M>0;j++){ if(mem[j].age>=_min&&mem[j].age<=_max){ printf("%s %d %d\n",mem[j].name,mem[j].age,mem[j].worth); flag=true; M–; } } if(!flag) printf(“None\n”); } system(“pause”); return 0;}