#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; struct node{ char name[30]; int p, q; double r; }N[105]; bool cmp(node n1, node n2) { return n1.r > n2.r; } int main() { int t; int n; scanf("%d", &t); while(t--) { scanf("%d", &n); getchar(); for(int i = 0; i < n; i++) { scanf("%s %d %d", N[i].name, &N[i].p, &N[i].q); N[i].r = 1.0 * N[i].p / N[i].q; getchar(); } sort(N, N + n, cmp); for(int i = 0; i < n; i++) { printf("%d %s %d %d\n", i + 1, N[i].name, N[i].p, N[i].q); } } return 0; } |
Double click to view unformatted code.