#include<stdio.h> #include<string.h> #include<math.h> #define MAX 1000000+10 #define Max(a,b) a>b?a:b #define Min(a,b) a<b?a:b struct phone{ char name[20]; float p; float q; }Phone[100],temp; int main() { int t; scanf("%d",&t); while(t--) { double xjb[100]={0}; int i,j; int n; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s%f%f",Phone[i].name,&Phone[i].p,&Phone[i].q); xjb[i]=1.0*Phone[i].p/Phone[i].q; } int k=1; for(i=0;i<n;i++) { double max=0.0; int t=0; for(j=0;j<n;j++) { if(xjb[j]>max&&xjb[j]!=-1) { t=j; max=xjb[j]; } } printf("%d %s %.0f %.0f\n",k++,Phone[t].name,Phone[t].p,Phone[t].q); xjb[t]=-1; } } } |
Double click to view unformatted code.