#include<bits/stdc++.h> using namespace std; typedef long long ll; struct phone{ char name[25]; double p, q; double s; }ph[105]; bool cmp(phone a, phone b){ return a.s>b.s; } int main (){ int t, n; scanf("%d", &t); while(t--){ scanf("%d", &n); for(int i = 0;i < n;i++){ scanf("%s%lf%lf", ph[i].name, &ph[i].p, &ph[i].q); ph[i].s = ph[i].p/ph[i].q; } sort(ph, ph+n, cmp); for(int i = 0;i < n;i++){ printf("%d %s %.0lf %.0lf\n", i+1, ph[i].name, ph[i].p, ph[i].q); } } return 0; } |
Double click to view unformatted code.