Racing Horses | CodeChef

i am not getting whats wrong in these,
#include
#include <bits/stdc++.h>
using namespace std;

int main()
{
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int s[n],clen,i;
for(i=0;i<n;i++)
cin>>s[i]; //4 9 1 32 13
sort(s,s+n); //1 4 9 13 32 after sorting
//n=5 ,5 elements

clen=s[1]-s[0];
for(i=1;i<n-1;i++){
    if(clen>(s[i+1]-s[i]))
    clen=s[i+1]-s[i];
else
    continue;
}
cout<<clen;
}
return 0;

}

"Please format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile: " - @ssjgz

2 Likes

You are missing newline character.

cout << clen << endl;
1 Like