Created
March 16, 2017 17:34
-
-
Save ninpl/1c2673929751f7baf5471a5a365ab1d6 to your computer and use it in GitHub Desktop.
Calcula la distancia entre dos puntos en un plano XY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Practica para refrescar la sintaxis de C++ | |
| #include <iostream> | |
| #include <cmath> | |
| using namespace std; | |
| int main() | |
| { | |
| // Calcula la distancia entre dos puntos en un plano XY | |
| int x1,y1,x2,y2; | |
| double distancia; | |
| cout<<"PUNTO 1"<<endl; | |
| cout<<"X :"; | |
| cin>>x1; | |
| cout<<"Y :"; | |
| cin>>y1; | |
| cout<<"PUNTO 2"<<endl; | |
| cout<<"X :"; | |
| cin>>x2; | |
| cout<<"Y :"; | |
| cin>>y2; | |
| distancia = sqrt(pow(x2-x1,2) + pow(y2-y1,2)); | |
| cout<<"La distancia es "<<distancia<<endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment