195: Find all elements in array of integers which have at-least two greater
// C++ Exercises: Find all elements in array of integers which have at-least two greater elements
#include <iostream>
using namespace std;
int main()
{
int size;
cout << "Enter the size of array: ";
cin >> size;
int array[size];
for (int i = 0; i < size; i++)
{
cout << "Enter a number for index " << i << ": ";
cin >> array[i];
}
system("cls");
cout << "All numbers having atleast two greater elements are: ";
for (int i = 0; i < size; i++)
{
int count = 0;
for (int j = i + 1; j < size; j++)
{
if (array[i] < array[j])
{
count++;
}
}
if (count >= 2)
{
cout << array[i] << ' ';
}
}
return 0;
}
Comments
Post a Comment