#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #define N 100 using namespace std; struct shouji { char name[50]; int xn; int jg; double xjb; }; bool cmp(shouji a,shouji b) { return a.xjb>b.xjb; } int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); struct shouji sj[n+1]; for(int i=0;i<n;i++) { scanf("%s%d%d",&sj[i].name,&sj[i].xn,&sj[i].jg); //scanf("%d%d",); sj[i].xjb=(double)sj[i].xn/sj[i].jg; } sort(sj,sj+n,cmp); for(int i=0;i<n;i++) { printf("%d %s %d %d\n",i+1,sj[i].name,sj[i].xn,sj[i].jg); /*if(i<n-1) printf("\n");*/ } } return 0; } |
Double click to view unformatted code.