四舍五入保留一位小数 搞错了
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
using namespace std;
int main()
{
int i=0,n=0,x=0,s=0,zhong1=0;
float zhong2;
vector<int>num;
cin>>n;
for(i=0;i<n;i++)
{
cin>>x;
num.push_back(x);
}
sort(num.begin(),num.end());//正序从小到大
cout<<num[n-1]<<" ";
if(n%2==0)
{
s=num[(n/2)-1]+num[n/2];
if(s%2!=0)//说明会出现小数
{
zhong2=s/2.0;
cout << setiosflags(ios::fixed) << setprecision(1) << zhong2 << " " ;
}
else
{
zhong1=s/2;
cout<<zhong1<<" ";
}
}
else
{
zhong1=num[n/2];
cout<<zhong1<<" ";
}
cout<<num[0]<<endl;
return 0;
}