CCF | 小中大

问题描述

试题编号: 201903-1
试题名称: 小中大
时间限制: 1.0s
内存限制: 512.0MB
问题描述:

 

 

 

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     int n;
 7     double maxn,minn,num,midn;
 8     cin>>n;
 9     maxn = 0;
10     minn = 0;
11     midn = 0;
12     if(n%2 == 1) {
13         cin>>minn;
14 
15         for(int i = 1; i < n; i++) {
16             if(i == (n-1)/2) {
17                 cin>>midn;
18             }else if(i == n-1){
19                 cin>>maxn;
20             } else {
21                 cin>>num;
22             }
23         }
24     } else {
25         cin>>minn;
26 
27         for(int i = 1; i < n; i++) {
28             if(i == (n-1)/2 || i == n/2) {
29                 cin>>num;
30                 midn += num;
31             }else if(i == n-1){
32                 cin>>maxn;
33             } else {
34                 cin>>num;
35             }
36         }
37 
38         midn = midn / 2;
39     }
40 
41     if(minn > maxn)
42         swap(minn,maxn);
43 
44     int maxnn = (int)maxn;
45     maxn - maxnn == 0 ? printf("%.0lf",maxn) : printf("%.1lf",maxn);
46     int midnn = (int)midn;
47     midn - midnn == 0 ? printf(" %.0lf",midn) : printf(" %.1lf",midn);
48     int minnn = (int)minn;
49     minn - minnn == 0 ? printf(" %.0lf",minn) : printf(" %.1lf",minnn);
50 
51     return 0;
52 }

 

posted @ 2019-09-02 11:10  听说这是最长的名字了  阅读(1028)  评论(0编辑  收藏  举报