内容目录
多关键字排序
#include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<cmath> #include<functional> #include<algorithm> using namespace std; #define MAXN (500000) int n; struct score { int no,a,b,c,d,e,f; friend bool operator<(const score a,const score b) { return (a.a!=b.a)?a.a>b.a:(a.b!=b.b)?a.b>b.b:(a.c!=b.c)?a.c>b.c:(a.d!=b.d)?a.d>b.d:(a.e!=b.e)?a.e>b.e:(a.f!=b.f)?a.f>b.f:a.no<b.no; } }a[MAXN]; int main() { scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d%d%d%d%d%d%d",&a[i].no,&a[i].a,&a[i].b,&a[i].c,&a[i].d,&a[i].e,&a[i].f); sort(a+1,a+1+n); for (int i=1;i<=n;i++) printf("%d %d %d %d %d %d %dn",a[i].no,a[i].a,a[i].b,a[i].c,a[i].d,a[i].e,a[i].f); return 0; }