实验思路:编写函数利用((x1-x2)^+(y1-y2)^再求平方根)可得距离。
#include <iostream>
#include <cmath>
using namespace std;
void dis(double x1, double y1, double x2, double y2){
cout << sqrt(pow((x1-x2),2)+pow((y1-y2),2)) << endl;
return;
}
int main(){
double a,b,c,d;
cout << "Please enter the coordinates of the two points, respectively " << endl;
cin >> a >> b >> c >> d;
cout << "The distance between these two points is " << endl;
dis( a, b, c, d);
return 0;
}