Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int interval(int n, int v[101]) {
- int min, max, c = 0;
- if (v[1] < v[n]) {
- min = v[1];
- max = v[n];
- }
- else {
- min = v[n];
- max = v[1];
- }
- for (int i = 1; i <= n; i++)
- if (min <= v[i] && v[i] <= max)
- c++;
- return c;
- }
- int main() {
- int n, v[101];
- cin >> n;
- for (int i = 1; i <= n; i++)
- cin >> v[i];
- cout << interval(n, v);
- cout << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment