I want to calculate the Euclidean distance using the following formula:
SoItried,makingthiscode:
#defineSLEEP_11000voidHeaderClass::DistanciaEuclidianaEntrePontos(){intx1,x2,y1,y2,distancia;std::cout<<"Coordenadas ponto 1 (x): ";
std::cin >> x1;
std::cout << "Coordenadas ponto 1 (y): ";
std::cin >> y1;
Sleep(SLEEP_1);
std::cout << "Coordenadas ponto 2 (x): ";
std::cin >> x2;
std::cout << "Coordenadas ponto 2 (y): ";
std::cin >> y2;
Sleep(SLEEP_1);
distancia = sqrt(((x2 - x1) ^ 2) + ((y2 - y1) ^ 2));
std::cout << "Distancia Euclidiana: " << distancia << std::endl;
}
But I still can not get what I want ...
For example:
√ (4-7) ² + (2-5) ² = 12
but the program says: