文章
105
粉丝
69
获赞
117
访问
57.5k
题目叙述不清,需要特判
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N];
int n;
int main()
{
cin >> n;
int a_max = 0, a_min = 1010;
for(int i = 0; i < n; i ++)
{
cin >> a[i];
a_max = max(a_max, a[i]);
a_min = min(a_min, a[i]);
}
if(a_max == a_min) //特判
{
for(int i = 1; i < n - 1; i ++)
cout << a[i] << " ";
return 0;
}
for(int i = 0; i < n; i ++)
if(a[i] != a_max && a[i] != a_min)
cout << a[i] << " ";
return 0;
}
登录后发布评论
暂无评论,来抢沙发