fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,n,i,j,min,d,a;
  6. cin>>t;
  7. while(t--)
  8. {
  9. cin>>n;
  10. int s[n];
  11. for(i=0;i<n;i++)
  12. cin>>s[i];
  13. for (i = 0; i < n; ++i)
  14. {
  15. for (j = i + 1; j < n; ++j)
  16. {
  17. if (s[i] < s[j])
  18. {
  19. a = s[i];
  20. s[i] = s[j];
  21. s[j] = a;
  22. }
  23. }
  24. }
  25. min=s[0];
  26. for(i=0;i<n-1;i++)
  27. {
  28. d=s[i]-s[i+1];
  29. if(min>d)
  30. min=d;
  31. }
  32. cout<<min;
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0s 2744KB
stdin
1
5
4 9 1 32 13
stdout
3