#include<stdio.h> #include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<vector> #include<cmath> #include<stack> using namespace std; struct jihe { string name; double fs; double jg; double xjb; }; jihe str[1000]; bool cmp(jihe a, jihe b) { return a.xjb > b.xjb; } int main() { int n; cin >> n; while (n--) { int g; int flag = 1; cin >> g; for (int i = 0; i < g; i++) { cin >> str[i].name >> str[i].fs >> str[i].jg; str[i].xjb = str[i].fs / str[i].jg; } sort(str, str + g, cmp); for (int i = 0; i < g; i++) { cout<<flag<<" "<< str[i].name <<" "<< str[i].fs<<" "<<str[i].jg<<endl; flag++; } } return 0; } |
Double click to view unformatted code.