output error

i use devc++ 4.9.9.2 in which language should i submit my code
and plz find error in the given code it is for problem stepford houses my comiler is giving correct ouput.

#include<iostream>
using namespace std;
void check(long int *p,long int n);
int main()
{
    long int i,*p,n;
    cout<<"enter the number of buildings:\n";
    cin>>n;
    p=new long int[n];
    cout<<"enter the height of respective buildings:\n";
    for(i=0;i<n;i++)
    cin>>p[i];
    cout<<"\nOUTPUT:\n";
    check(p,n);   
    return 0;
}
void check(long int *p,long int n)
{
     long int i,j,c=0;
     for(i=0;i<n-1;i++)
                     for(j=i+1;j<n;j++)
                                     if(p[i]>p[j])
                                                  c++;
     cout<<c<<endl;
}

You have to read FAQ, especially section “How does Codechef test whether my solution is correct or not”.

This part is important:

If your program starts by printing ‘Enter the number’ and the problem does not tell you to do so, then since this is not part of the correct output, you will be never be judged correct regardless of what the rest of your program does.

It’s related to your code cout<<"\nOUTPUT:\n"; and other parts.

1 Like

your code should output exactly what is expected not a char more nor less. May be you can figure out the rest :slight_smile:

//