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