C++程序填空 5
#include<iostream.h>#include<cmath.h>classTPoint{private:doublex,y;public:TPoint(doub...
#include <iostream.h>
#include <cmath.h>
class TPoint
{
private:
double x,y;
public:
TPoint(double a,double b)
{
___x=a_______;
__________;
cout<<”点:(“<<x<<”,”<<y<<”)”<<endl;
}
friend double distance(TPoint &a,TPoint &b) //求两点间的距离
{
return ________________________________;
}
};
void main( )
{ TPoint p1(2,1),p2(5,5);
cout<<”上述两点之间的距离”<< _____________<<endl; } 展开
#include <cmath.h>
class TPoint
{
private:
double x,y;
public:
TPoint(double a,double b)
{
___x=a_______;
__________;
cout<<”点:(“<<x<<”,”<<y<<”)”<<endl;
}
friend double distance(TPoint &a,TPoint &b) //求两点间的距离
{
return ________________________________;
}
};
void main( )
{ TPoint p1(2,1),p2(5,5);
cout<<”上述两点之间的距离”<< _____________<<endl; } 展开
展开全部
一楼的少侠已经回答正确了,我在这里改一下,希望大家使用C++标准来编程。this指针在这里可以省。这里还是用到了C的.h文件。对于主函数来说,在C++标准中是明确注明不可以用 void 的,只能用int 并且有返回值 0。void 是C的风格,在一些C++程序中是不可以用void的。希望大家都用C++标准编程有利于C++的发展和相互交流。
#include <iostream.h>
#include <math.h>
class TPoint
{
private:
double x,y;
public:
TPoint(double a,double b)
{
x = a;
y = b;
cout<<"点:("<<x<<","<<y<<")"<<endl;
}
friend double distance(TPoint &a,TPoint &b) //求两点间的距离
{
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
};
int main( )
{
TPoint p1(2,1),p2(5,5);
cout<<"上述两点之间的距离"<<distance(p1,p2) <<endl;
return 0;
}
#include <iostream.h>
#include <math.h>
class TPoint
{
private:
double x,y;
public:
TPoint(double a,double b)
{
x = a;
y = b;
cout<<"点:("<<x<<","<<y<<")"<<endl;
}
friend double distance(TPoint &a,TPoint &b) //求两点间的距离
{
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
};
int main( )
{
TPoint p1(2,1),p2(5,5);
cout<<"上述两点之间的距离"<<distance(p1,p2) <<endl;
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <iostream.h>
#include <math.h>
class TPoint
{
private:
double x,y;
public:
TPoint(double a,double b)
{
this->x = a;
this->y = b;
cout<<"点:("<<x<<","<<y<<")"<<endl;
}
friend double distance(TPoint &a,TPoint &b) //求两点间的距离
{
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
};
void main( )
{
TPoint p1(2,1),p2(5,5);
cout<<"上述两点之间的距离"<< distance(p1,p2) <<endl;
}
#include <math.h>
class TPoint
{
private:
double x,y;
public:
TPoint(double a,double b)
{
this->x = a;
this->y = b;
cout<<"点:("<<x<<","<<y<<")"<<endl;
}
friend double distance(TPoint &a,TPoint &b) //求两点间的距离
{
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
};
void main( )
{
TPoint p1(2,1),p2(5,5);
cout<<"上述两点之间的距离"<< distance(p1,p2) <<endl;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
(1)int(2)int y=b
三四问没法写,题出错了
三四问没法写,题出错了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询