小中大(201903-1)
作者:互联网
试题编号: | 201903-1 |
试题名称: | 小中大 |
时间限制: | 1.0s |
内存限制: | 512.0MB |
问题描述: |
|
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
int n,maxx,minn;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
maxx=a[n-1];
minn=a[0];
if(n%2==1)
{
int mid=a[n/2];
cout<<maxx<<" "<<mid<<" "<<minn<<endl;
}
else
{
if((a[n/2]+a[n/2-1])%2==0)
{
int mid=(a[n/2]+a[n/2-1])/2;
cout<<maxx<<" "<<mid<<" "<<minn<<endl;
}
else
{
float mid=(a[n/2]+a[n/2-1])/2.0;
cout<<maxx<<" ";
printf("%.1f ",mid);
cout<<minn<<endl;
}
}
return 0;
}
标签:maxx,小中大,试题,minn,int,201903 来源: https://blog.csdn.net/m0_56585533/article/details/120358303