|
#include <iostream.h>
#include <math.h>
//#include <distance.h>
double distance(double a,double b,double c,double d)
{
int res;
res=squr((power((a-c),2)-power((b-d),2)),2);
if(res<0)
res=-res;
return res;
}
void main()
{
double a,b,c,d;
cout<<"Please input two points,like 2 3 reprents (2,3):"<<endl;
cin>>a>>b>>c>>d;
cout<<"the distance of the two points is :"<<distance(a,b,c,d)<<endl;
}
This is a program to calculate the distance between two points. The methods in the math class are not clear. Please help me look at the calculation statement res=squr((power((ac),2)-power((bd),2)),2 );
How to change? ? Thank you |
|