#include <stdio.h> int main() { int t; scanf("%d",&t); while(t) { int n,i,j,tmp; scanf("%d",&n); int a[n]; for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n1;i++) { for(j=0;j<n1;j++) { if(a[j]>a[j+1]) { tmp=a[j]; a[j]=a[j+1]; a[j+1]=tmp; } } } for(i=0;i<n2;i++) { printf("%d ",a[i]); } printf("\n"); } return 0; }
Problem Description
Given an array of n distinct elements, the task is to find all elements in array which have atleast two greater elements than themselves.
Examples:
Input : A[] = {2, 8, 7, 1, 5};
Output : 1 2 5
The output three elements have two or more greater elements
Input : A[] = {7, 2, 3, 4, 9, 1};
Output : 2 1 3 4
Input:
The first line of input contains an integer T denoting the no of test cases. Each test case contains two lines .
The first line of input contains an integer n denoting the size of the array. Then in the next are n space separated values of the array.
Output:
For each test case in a new line print the space separated sorted values denoting the elements in array which have atleast two greater elements than themselves.
Constraints:
1<=T<=100
1<=N<=100
1<=A[]<=100

Test Case 1
Input (stdin)
2 5 2 8 7 1 5 6 7 2 3 4 9 1
Expected Output
1 2 5 2 1 3 4

Test Case 2
Input (stdin)
2 6 2 8 7 1 5 9 5 7 2 3 4 9
Expected Output
1 2 5 7 2 3 4