El quiz 3 primero se relaciona con el plano cartesiano , y algunos puntos, el programa puede calcular la distancia entre los dos puntos , son dados por el usuario al azar , usando el teorema de la Pitágora solucionarla.
//CODE:
# include <iostream>
# include <cmath>
using namespace std;
/*int x1, x2, y, y2;
void Distance(int x1, int x2, int y, int y2) {
int dx, dy, dist, C;
dx=(x2-x1);
dy=(y2-y);
C=((dx*dx)+(dy*dy));
dist=sqrt(C);
std::cout << “dx–“<<dx << std::endl;
std::cout << “dy–“<<dy << std::endl;
std::cout << “The distance between the points is… “<<dist << std::endl;
}*/
int main(int argc, char const *argv[]) {
int dx, dy, x1, x2, y, y2, dist, C;
std::cout << “This program calculates the distance between two points in the cartesian plane.” << std::endl;
std::cout << “Next enter the coordenates of the first point” << std::endl;
std::cout << “Please enter x1)” << std::endl;
std::cin >> x1;
std::cout << “Pease enter y1” << std::endl;
std::cin >> y;
std::cout << “Please enter x2” << std::endl;
std::cin >> x2;
std::cout << “Please enter y2” << std::endl;
std::cin >> y2;
dx=(x2-x1);
dy=(y2-y);
C=(pow(dx,2)+pow(dy,2));
dist=sqrt(C);
std::cout << “The distance between the points is… “<<dist << std::endl;
//Distance();
return 0;
}
QUIZ 3 by lilihecblog is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.