Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- double x_1, x_2, y_1, y_2, distance;
- cout << "Enter the coordinates of the first point:" << endl;
- cout << " X = ";
- cin >> x_1;
- cout << " Y = ";
- cin >> y_1;
- cout << endl << "Enter the coordinates of the second point:" << endl;
- cout << " X = ";
- cin >> x_2;
- cout << " Y = ";
- cin >> y_2;
- distance = sqrt((x_2 - x_1) * (x_2 - x_1) + (y_2 - y_1) * (y_2 - y_1));
- cout << endl << "The distance between [" << x_1 << ";" << y_1 << "] and [" << x_2 << ";" << y_2 << "] is " << distance;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement