title: printing the closest pair of points
body: <p>I was writing this code to find the minimum distance between 2 points.The code I have written gives me the minimum distance correctly but does not give the correct coordinates from which the minimum distance is computed.Kindly help me identify the problem according to me this is the correct approach to print the points as well along with the minimum distance.</p>
  
  <pre><code>#include&lt;bits/stdc++.h&gt;
  #define FOR(i,N) for(int i=0;i&lt;(N);i++)
  #define rep(i,a,n) for(int i=(a);i&lt;(n);i++)
  using namespace std;
  struct point {
  int x;
  int y;
  };
  
  typedef struct point point;
  void printarr(point arr[], int n) {for(int i = 0; i &lt; n; i++) cout &lt;&lt;                   
  arr[i].x &lt;&lt; " " &lt;&lt; arr[i].y &lt;&lt; endl; cout &lt;&lt; endl; 
  bool comparex(const point&amp; X, const point&amp; Y) { return X.x &lt; Y.x; }
  bool comparey(const point&amp; X, const point&amp; Y) { return X.y &lt; Y.y; }
  
  float getdis(point X, point Y) { return sqrt((X.x - Y.x)*(X.x - Y.x) + (X.y         
  - Y.y)*(X.y - Y.y)); }
  float brutedis(point P[], int n, point A[]) {
  float d = INT_MAX;
  float temp;
  FOR(i, n) {
      rep(j, i+1, n) {
          temp = getdis(P[i],P[j]);
          if(temp &lt; d) {
              d = temp;
              A[0].x = P[i].x; A[0].y = P[i].y;
              A[1].x = P[j].x ; A[1].y = P[j].y;
          }
      }
  }
  return d;
  }
  
  float stripdis(point P[], int n, float d, point A[]) {
  float temp = d;
  float dis;
  sort(P, P + n, comparey);
  FOR(i, n) {
      rep(j,i+1,n) {
          if(abs(P[j].y - P[i].y) &lt; d) {
              dis = getdis(P[j], P[i]);
              if(dis &lt; temp) {
                  temp = dis;
                  A[0].x = P[i].x; A[0].y = P[i].y;
                  A[1].x = P[j].x ; A[1].y = P[j].y;
              }
          }
      }
    }
     return temp;
     }
  
    float solve(point P[], int n, point A[]) {
  
    if(n &lt;= 3) return brutedis(P, n, A);
  
    int mid = n/2;
    point M = P[mid];
   float d = min(solve(P, mid, A), solve(P+mid, n-mid, A));
  point strip[n];
  int j = 0;
  int i = 0;
  while(i &lt; n) {
      if(abs(P[i].x - M.x) &lt; d) strip[j++] = P[i];
      i++;
  }
  
  return min(d, stripdis(strip, j, d, A));
   }
  
   int main() {
  
  point P[] = {{0, 0}, {-4,1}, {-7, -2}, {4, 5}, {1, 1}};
  int n = sizeof(P) / sizeof(P[0]);
  sort(P, P+n, comparex);
  point A[2];
  cout &lt;&lt; "Minimum Distance = " &lt;&lt; solve(P, n, A) &lt;&lt; "\n";
  printarr(A, 2);
  //printarr(P, n);
  return 0;
  }
  </code></pre>