1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <iostream> #include <cstdio> #include <vector> #include <string> #include <algorithm> using namespace std; int arr[100005]; int main(){ int n; scanf("%d",&n); int t; int max_num,min_num,mid_num=0; double mid_num_d=0; for(int i=0;i<n;i++){ scanf("%d",&arr[i]); } max_num=max(arr[0],arr[n-1]); min_num=min(arr[0],arr[n-1]); bool flag=false; if(n%2==1){ mid_num=arr[n/2]; }else{ mid_num=arr[n/2]+arr[n/2-1]; if(mid_num%2==0){ mid_num/=2; }else{ mid_num_d=(double)mid_num/2; flag=true; } } if(!flag) printf("%d %d %d\n", max_num, mid_num, min_num); else printf("%d %.1lf %d\n", max_num, mid_num_d, min_num); } |
CSP 201903-1 小中大
发表评论