racing horses, code is not accepted

i have written this code for problem racing horses in easy section.
but its not accepted, i dont understand whats wrong with it. please help.

#include<stdio.h>
#include<math.h>
 
void main(){
int T;
int n[10];
int a[500];
int min[10],t,k;

    //input test cases

scanf("%d",&T);


int i=0,j=0;

    //input horses skills for all cases

while(T--)
{
scanf("%d", &n[i]);

j=0;

t=n[i];
 
  while(t--)
{
        scanf("%d",&a[j]);
        j++; 

        }

min[i]=abs(a[0]-a[1]);

    //checking the min difference

  for(j=0;j<n[i];j++)
   {
       for(k=j+1;k<n[i];k++)
         {if(abs(a[k]-a[j])<min[i]) min[i]=abs(a[k]-a[j]);

         }
    }


i++;

}


for(j=0;j<T;j++)
printf("%d\n", min[j]);

}

Hello sonu77,

Your code’s a bit hard to read as it was not properly formatted… I recall code should be put inside code tags which are represented as 101 010 block on the edition bar above this text box…

printf("%d", num);
//this is a second line in code format

for example, as with the above format…

With that cleared out, I can immediately see a problem with your code as the line:

printf("min :%dn", min[j]);

is printing to standard output more things that the ones that are strictly necessary and that issue alone will cause you a Wrong Answer as the code output format is not the same as the specified by the problem statement…

Hope I could help,

Bruno

still the code is not accepted

Well, this is all cleared out in the FAQ section:

Regarding the NZEC error:

" For C users, this will be generated if your main method does not have a return 0;"

So, try to change your main() to return an int and terminate your code with return 0;

thank you very much

3 Likes
//