Question description
Nancy, Simon, and Swati were all attending campus interviews.
they got selected for the second round.
Nancy failed to clear the second round and others to selected for the next round of interviews.
Nancy discussed with her friend the question which came in the interview.
one of the questions have given an array of n distinct elements, the task is to find all elements in array which have at-least two greater elements than themselves.
But it's in the syllabus of his exam. So can you help to create a program in the specified concept to get an offer in the next interview ?.
Constraints
1≤ N ≤1000
Examples:
Input : A[] = {2, 8, 7, 1, 5};
#include<stdio.h>
void sort(int a[],int n)
{
int i,j,t;
for(i=0;i<n-1;i++)
for(j=0;j<n-i-1;j++)
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,i;
scanf("%d",&n);
int a[1000];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,n);
for(i=0;i<n-2;i++)
printf("%d ",a[i]);
printf("\n");
}
return 0;
}
0 Comments