首页 > 试题广场 >

阅读下列程序,写出运行结果: #include

[问答题]
阅读下列程序,写出运行结果:
#include<iostream>
using namespace std;
#include<cmath>
class Point
{
public :
Point( float x, float y )
{ a = x; b = y;  cout<<"点( "<<a<<", "<<b<<" )"; }
friend double d( Point &A, Point &B )
{ return sqrt((A.a-B.a)*(A.a-B.a)+(A.b-B.b)*(A.b-B.b)); }
private:
double a, b;
};
int main()
{
Point p1( 2, 3 );
cout << "到";
Point p2( 4, 5 );
cout << "的距离是:" << d( p1,p2 ) << endl;
}

推荐

点(3,4)到点(4,5)的距离是:2.82843

发表于 2018-05-07 15:08:13 回复(0)