 # Medel help

Medel Problem
indent preformatted text by 4 spaces
#include
#include<conio.h>
using namespace std;
int main()
{
int T;
cout<<“enter T”;
cin>>T;
while(T–)
{
int n,b,c,d;
int a;
cout<<“Enter n”;
cin>>n;
cout<<“Enter elements :”;
for(int i=0;i<=n-1;i++)
{
cin>>a[i];
}
for(int j=0;j<=n-3;j++)
{
if(a<a&&a<a)
{
if(a>a){
b=a;
a=a;
a=b;
}
}
else if(a>a&&a>a)
{
if(a<a){
d=a;
a=a;
a=d;
}
}
else if((a>a&&a<a)||(a<a&&a>a))
{
c=a;
a=a;
a=c;
}
//cout<<"\n “<<a<<” “<<a<<” “<<a<<”\n";
a=a;
a=a[j+3];
}
cout<<a<<" ";
cout<<a;
}
return 0;
}
I tried to run this code in eclipse ide and it worked perfectly for me.
But when I tried to run this code in codechef’s ide and submitted this solution for the medel problem,I got wrong answer.I don’t understand where I commited a mistake.Your help is very appreciated.Please pardon the broken english I have used.
Thank You:smiley:

#include’ is there in 1st line of the code instead of ‘#include

The problem is easy, just analyse different test-cases, and you will see that after removing all the medians from a tuple of three numbers, you will be left with the min and max element in the sequence.
Just keep track of the index of min and max, because in the output order matters.
Refer the solution in C.

P.S: Refer to the following guidelines when you post again later.

Suggestions for asking the question on this forum.
• Format your code as the forum software messed it up.
• Give the link to problem which you are trying to solve.
• Explain your source-code in plain english, what idea you are trying to implement, yeah we can go through your code but it will be time consuming, it would be better if you explain it.

After doing the above things, then you can expect help from the community.

Peace 