|
发表于 2021-11-26 09:54:18
From FishC Mobile
|
显示全部楼层
本帖最后由 傻眼貓咪 于 2021-11-26 11:18 编辑
- #include <stdio.h>
- int main() {
- int N, first, second, third;
- float x = 32767, y = 32767, z = 32767;
- scanf("%d", &N);
- for(size_t i = 0; i < N; i++){
- int a;
- float b, c;
- scanf("%d%f%f", &a, &b, &c);
- if(b/c <= x){
- z = y;
- y = x;
- x = b/c;
-
- third = second;
- second = first;
- first = a;
- }
- else if(b/c <= y){
- z = y;
- y = b/c;
-
- third = second;
- second = a;
- }
- else if(b/c <= z){
- z = b/c;
- third = a;
- }
- }
- int max, min, mid;
- max = first > second ? first : second > third ? second : third;
- min = first < second ? first : second < third ? second : third;
- mid = first != max && first != min ? first : second != max && second != min ? second : third;
- (x != y) && (x != z) && (y != z) ? printf("%d %d %d", first, second, third) :\
- (x == y) && (x != z) ? printf("%d %d %d", first < second ? first : second, first > second ? first : second, third) :\
- (y == z) && (y != x) ? printf("%d %d %d", first, second < third ? second : third, second > third ? first : second) :\
- printf("%d %d %d", min, mid, max);
- return 0;
- }
复制代码 **我刚刚用手机写代码,没有检查是否正确 |
|