We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int main () {
int n = 0; int co_max = -1; int co_min = 0;
int arr[n], Max, Min;
do {
cin >> n;
} while (n <= 0);
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
for (int i = 0; i < n; ++i) {
if (arr[i] > Max) {
Max = arr[i];
++co_max;
}
if (arr[i] < Min) {
Min = arr[i];
++co_min;
}
}
cout << co_max << " " << co_min <
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Breaking the Records
You are viewing a single comment's thread. Return to all comments →
where is the problem ?
include
using namespace std;
int main () { int n = 0; int co_max = -1; int co_min = 0; int arr[n], Max, Min; do { cin >> n; } while (n <= 0); for (int i = 0; i < n; ++i) { cin >> arr[i]; } for (int i = 0; i < n; ++i) { if (arr[i] > Max) { Max = arr[i]; ++co_max; } if (arr[i] < Min) { Min = arr[i]; ++co_min; } } cout << co_max << " " << co_min <