You Are All Excellent 排序
来源:互联网 发布:js隐藏select标签 编辑:程序博客网 时间:2024/06/04 18:47
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;}
0 0
- You Are All Excellent 排序
- You Are All Excellent 1785
- hdu1785 You Are All Excellent
- HDU:You Are All Excellent
- HDOJ1785 You Are All Excellent
- hdu1785 You Are All Excellent (极角排序)
- hdu 1785 You Are All Excellent
- hdu 1785 You Are All Excellent
- hdu 1785 You Are All Excellent
- HDU 1785 You Are All Excellent
- HDU1785 You Are All Excellent【余弦】【水题】
- HDU 1785 You Are All Excellent
- HDU 1785 You Are All Excellent
- HDOJ 1785 You Are All Excellent
- hdoj problem1785 You Are All Excellent(结构体sort排序&&三角函数)
- HDU 1785 You Are All Excellent(斜率排序+结构体)
- HDU 1785 You Are All Excellent(数学题)
- You Are All Excellent(余弦排比0~180)
- 对互联网海量数据实时计算的理解
- sort
- Zookeeper资料文章整理
- Python超级程序员使用的开发工具
- maven项目 无法运行main方法的问题。java.lang.ClassNotFoundException
- You Are All Excellent 排序
- SD卡哈发生地方很少的发生的
- 编写Android启动页面的方法
- Java final
- Python一日一练02----诗词生成器
- spark rdd countByValue
- InfoQ精选文档
- 可变参数, va_start, va_arg, va_end
- leetcode:String to Integer (atoi)