fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. Console.WriteLine(
  15. Solution(new int[] { 1, 4,-3 })
  16. );
  17. }
  18.  
  19. static int Solution(int[] array)
  20. {
  21. int min = Math.Abs(array[0] * 2);
  22. int absResult;
  23.  
  24. for (int i = 0; i < array.Length; i++)
  25. {
  26. for (int j = i; j < array.Length; j++)
  27. {
  28. absResult = Math.Abs(array[i] + array[j]);
  29. if (absResult < min)
  30. {
  31. min = absResult;
  32. if (absResult == 0)
  33. return 0;
  34. }
  35. }
  36. }
  37. return min;
  38. }
  39. }
  40. }
  41.  
Success #stdin #stdout 0.04s 23936KB
stdin
Standard input is empty
stdout
1