Codeforces 768A 暴力

版权声明:欢迎转载,不要求署名~~~ https://blog.csdn.net/shadandeajian/article/details/82148081

传送门:题目

题意:

给一个序列,查找既不是最大值,也不是最小值的个数

题解:

sort,然后计数中间的就好了。

AC代码:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define INF 0x3f3f3f3f
using namespace std;

const int maxn = 1e5 + 10;
int a[maxn];
int main(void) {
    int n,sum=0;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    for (int i = 1; i < n - 1; i++)
        if (a[i] != a[0] and a[i] != a[n - 1])
            sum ++;
    cout << sum << endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/shadandeajian/article/details/82148081
今日推荐