C++的一道简单的题,计算点和面的距离,我的提示出错大家帮我看喜下哪里错了吧?谢谢

#include<iostream>#include<cmath>usingnamespacestd;classMian;classPoint{public:Point(... #include<iostream>
#include<cmath>
using namespace std;
class Mian;
class Point{
public:
Point(float x=0,float y=0,float z=0){}
float getX(){return x;}
float getY(){return y;}
float getZ(){return z;}
friend float Mian(Point &p1,Mian &m1);
friend float dist(Point &p1,Mian &m1);
private:
float x,y,z;
};
class Mian{
public:
Mian(float a=0,float b=0,float c=0,float d=0){}
float getA(){return a;}
float getB(){return b;}
float getC(){return c;}
float getD(){return d;}
friend float dist(Point &p1,Mian &m1);
private:
float a,b,c,d;
};

float dist(Point &p1,Mian &m1){
float x=p1.x*m1.a;
float y=p1.y*m1.b;
float z=p1.z*m1.c;
float d=m1.d;
float a=m1.a;
float b=m1.b;
float c=m1.c;
return static_cast<float>(sqrt((x+y+z+d)*(x+y+z+d))/sqrt(a*a+b*b+c*c));
}
float main(){
float a,b,c,d,x,y;
cout<<"请输入点的坐标x,y"<<endl;
cin>>x>>y;
cout<<"请输入这个面ax+by+cz+d=0的系数a,b,c,d"<<endl;
cin>>a>>b>>c>>d;
Point myp1(x,y);
Mian mym1(a,b,c,d);
cout<<"点的面的距离为:"<<endl;
cout<<dist(myp1,mym1)<<endl;
return 0;
}
展开
 我来答
sine882010
推荐于2016-03-25 · TA获得超过320个赞
知道小有建树答主
回答量:167
采纳率:0%
帮助的人:213万
展开全部
//如有问题,再探讨
#include<iostream>
#include<cmath>
using namespace std;
class Mian;
class Point{
public:
Point(float x=0,float y=0,float z=0){}
float getX(){return x;}
float getY(){return y;}
float getZ(){return z;}
//friend float Mian(Point &p1,Mian &m1); 这里注释掉,要么函数名改改,不要和类Mian重名了
friend float _Mian(Point &p1,Mian &m1);
friend float dist(Point &p1,Mian &m1);
private:
float x,y,z;
};
class Mian{
public:
Mian(float a=0,float b=0,float c=0,float d=0){}
float getA(){return a;}
float getB(){return b;}
float getC(){return c;}
float getD(){return d;}
friend float dist(Point &p1,Mian &m1);
private:
float a,b,c,d;
};

float dist(Point &p1,Mian &m1)
{
float x=p1.x*m1.a;
float y=p1.y*m1.b;
float z=p1.z*m1.c;
float d=m1.d;
float a=m1.a;
float b=m1.b;
float c=m1.c;
return static_cast<float>(sqrt((x+y+z+d)*(x+y+z+d))/sqrt(a*a+b*b+c*c));
}
float main()
{
float a,b,c,d,x,y;
cout<<"请输入点的坐标x,y"<<endl;
cin>>x>>y;
cout<<"请输入这个面ax+by+cz+d=0的系数a,b,c,d"<<endl;
cin>>a>>b>>c>>d;
Point myp1(x,y);
Mian mym1(a,b,c,d);
cout<<"点的面的距离为:"<<endl;
cout<<dist(myp1,mym1)<<endl;
return 0;
}
追问
能告诉我为什么必须注释吗?谢谢
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2011-04-20
展开全部
算出的结果我不知道对不对
#include<iostream>
#include<cmath>
using namespace std;
class Mian;
class Point
{
public:
Point(float x=0,float y=0,float z=0){}
float getX(){return x;}
float getY(){return y;}
float getZ(){return z;}
// friend float Mian(Point &p1,Mian &m1);
friend float dist(Point &p1,Mian &m1);
private:
float x,y,z;
};
class Mian
{
public:
Mian(float a=0,float b=0,float c=0,float d=0){}
float getA(){return a;}
float getB(){return b;}
float getC(){return c;}
float getD(){return d;}
friend float dist(Point &p1,Mian &m1);
private:
float a,b,c,d;
};

float dist(Point &p1,Mian &m1){
float x=p1.x*m1.a;
float y=p1.y*m1.b;
float z=p1.z*m1.c;
float d=m1.d;
float a=m1.a;
float b=m1.b;
float c=m1.c;
return static_cast<float>(sqrt((x+y+z+d)*(x+y+z+d))/sqrt(a*a+b*b+c*c));
}
int main(){
float a,b,c,d,x,y;
cout<<"请输入点的坐标x,y"<<endl;
cin>>x>>y;
cout<<"请输入这个面ax+by+cz+d=0的系数a,b,c,d"<<endl;
cin>>a>>b>>c>>d;
Point myp1(x,y);
Mian mym1(a,b,c,d);
cout<<"点的面的距离为:"<<endl;
cout<<dist(myp1,mym1)<<endl;
return 0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
权同0gg
2011-04-20 · TA获得超过160个赞
知道小有建树答主
回答量:197
采纳率:0%
帮助的人:210万
展开全部
main函数怎么是float的,应该是 int main()
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式