#include <iostream> #include <cstdio> #include <algorithm> using namespace std; struct Phone{ string name; double p,q; }pho[999]; bool cmp(Phone a,Phone b){ return a.p/a.q>b.p/b.q; } int main(){ int T; cin>>T; while(T--){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>pho[i].name>>pho[i].p>>pho[i].q; } sort(pho,pho+n,cmp); for(int i=0;i<n;i++){ cout<<i+1<<" "<<pho[i].name<<" "<<pho[i].p<<" "<<pho[i].q<<endl; } } return 0; } |
Double click to view unformatted code.