水题,还是字典排序,没神马好说的;
#include#include #include #include #include #include #include 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.worth; }}int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=0;i 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;}