You Are All Excellent
#include<stdio.h> #include<math.h> struct people{ double x, y; double ability; }s[100], b; int adjust(people s[], int low, int high) { b = s[low]; double x = s[low].ability; while(low < high){ while(low < high && s[high].ability >= x) high--; if(low<high) { s[low] = s[high]; low++; } while(low < high && s[low].ability <= x) low++; if(low<high) { s[high] = s[low]; high--; } } s[low] = b; return low; } void qsort(people s[], int l, int r) { if(l < r){ int i = adjust(s, l, r); qsort(s, l, i-1); qsort(s, i+1, r); } } int main(){ int n; while(scanf("%d", &n) && n>=0){ for(int i=0; i<n; i++) { scanf("%lf%lf", &s[i].x, &s[i].y); s[i].ability = s[i].x / sqrt(s[i].y*s[i].y + s[i]. x*s[i]. x); //求余弦 } qsort(s, 0, n-1); for(int i=n-1; i>=0; i--) i==n-1? printf("%.1lf %.1lf", s[i].x, s[i].y) : printf(" %.1lf %.1lf", s[i].x, s[i].y); printf("\n"); } return 0; }