| |

VerySource

 Forgot password?
 Register
Search
View: 748|Reply: 3

About math

[Copy link]

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-12-15 23:00:01
| Show all posts |Read mode
#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
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-12-16 08:45:01
| Show all posts
res=sqrt( power(fabs(a-c),2)-power(fabs(b-d),2) );
Reply

Use magic Report

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-12-20 08:30:01
| Show all posts
What are fabs? Why add this power (a, b) to the power of b?
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-21 11:30:01
| Show all posts
fabs means absolute value
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list