title: c++ euclidean distance
body: <p>This code compiles and runs but does not output the correct distances.</p>
  
  <pre><code>for (int z = 0; z &lt; spaces_x; z++)
  {
      double dist=( ( (spaces[z][0]-x)^2) + ( (spaces[z][1]-y)^2) );
      dist = abs(dist);   
      dist = sqrt(dist);
      cout &lt;&lt; "for x " &lt;&lt; spaces[z][0] &lt;&lt;
              " for y " &lt;&lt; spaces[z][1] &lt;&lt;
              " dist is  "&lt;&lt; dist &lt;&lt; endl;
  
      if (dist &lt; min_dist)
      {
          min_dist = dist;
          index = z;
      }
  }
  </code></pre>
  
  <p>Does anyone have an idea what the problem could be?</p>