小中大

小中大


from CCF-CSP 2019-03-1
Time limit:1s
Memory limit:512MB

在这里插入图片描述
在这里插入图片描述


题目很简单注意小数就可以了。

ac代码:
#include<iostream>
using namespace std;
int n,x[100005];
int main(){
    
    
    cin>>n;
    for(int i = 1;i <= n;++i)
        cin>>x[i];
    if(x[1] > x[n])
        cout<<x[1];
    else
        cout<<x[n];
    if(n % 2 == 1)
        cout<<" "<<x[n / 2 + 1]<<" ";
    else{
    
    
        if((x[n / 2] + x[n / 2 + 1]) % 2 == 0)
            cout<<" "<<(x[n / 2] + x[n / 2 + 1]) / 2<<" ";
        else
            cout<<" "<<(x[n / 2] + x[n / 2 + 1]) / 2<<".5 ";
    }
    if(x[1] < x[n])
        cout<<x[1];
    else
        cout<<x[n];
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_45985728/article/details/115187006