1个回答
展开全部
求两坐标点距离?
#include <iostream>
#include <math.h>
using namespace std;
struct point
{
int x;
int y;
int z;
};
int main()
{
struct point p1,p2;
float d;
cout<<"输入两个坐标点:";
cin>>p1.x>>p1.y>>p1.z;
cin>>p2.x>>p2.y>>p2.z;
cout<<"两个点的坐标分别是:"<<endl;
cout<<"("<<p1.x<<","<<p1.y<<","<<p1.z<<")"<<endl;
cout<<"("<<p2.x<<","<<p2.y<<","<<p2.z<<")"<<endl;
d = sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z));
cout<<"两点之间的距离:"<<d<<endl;
return 0;
}
#include <iostream>
#include <math.h>
using namespace std;
struct point
{
int x;
int y;
int z;
};
int main()
{
struct point p1,p2;
float d;
cout<<"输入两个坐标点:";
cin>>p1.x>>p1.y>>p1.z;
cin>>p2.x>>p2.y>>p2.z;
cout<<"两个点的坐标分别是:"<<endl;
cout<<"("<<p1.x<<","<<p1.y<<","<<p1.z<<")"<<endl;
cout<<"("<<p2.x<<","<<p2.y<<","<<p2.z<<")"<<endl;
d = sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z));
cout<<"两点之间的距离:"<<d<<endl;
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询