fork download
  1. using System;
  2.  
  3. namespace Application
  4. {
  5. class Program
  6. {
  7. static int cmp(int i, int j, int[,] s)
  8. {
  9. int sum = 0;
  10. for(int k = 0; k < s.GetLength(1); ++k)
  11. {
  12. sum += (s[i,k]-s[j,k])*(s[i,k]-s[j,k]);
  13. }
  14. return sum;
  15. }
  16. static void Main(string[] args)
  17. {
  18. int[,] s = {{0, 1, 1, 1, 1},{0, 0, 1, 0, 1},
  19. {1, 1, 1, 1, 1},{0, 0, 0, 0, 0}};
  20.  
  21. int min = int.MaxValue, r1 = 0, r2 = 0;
  22. for(int i = 0; i < s.GetLength(0); ++i)
  23. for(int j = i+1; j < s.GetLength(0); ++j)
  24. {
  25. int diff = cmp(i,j,s);
  26. if (diff < min)
  27. {
  28. min = diff;
  29. r1 = i;
  30. r2 = j;
  31. }
  32. }
  33. Console.WriteLine(r1+" and "+r2);
  34.  
  35. }
  36. }
  37. }
  38.  
  39.  
Success #stdin #stdout 0.02s 24616KB
stdin
Standard input is empty
stdout
0 and 2