# include<cmath>
using namespace std;
class ball//定義空間球類
{
protecteed:
double x,y,z;//球心坐標
double r;//球半徑
public:
ball(double x,double y,double z,double r)//構造函數
{
this->x=x;
this->y=y;
this->z=z;
this->r=r;
}
double GetRadius()//返回球的半徑
{
return r;
}
double GetX()//返回x坐標
{
retrun x;
}
double GetY()//返回y坐標
{
retrun y;
}
double GetZ()//返回z坐標
{
retrun z;
}
};
void Relation(ball&a,ball&b)//比較球a,b關系
{
double distance=sqrt(pow(a.GetX()-b.GetX(),2),pow(a.GetY()-b.GetY(),2)pow(a.GetZ()-b.GetZ(),2));
double R=a.GetRadius()+b.GetRadius();
if(distance==R)
cout<<"相切"<<endl;
else if(distance>R)
cout<<"相離"<<endl;
else
cout<<"相交"<<endl;
}
int main()
{
ball a(0,0,0,1);
ball b(1,1,1,1);
a.Relation(a,b);
return 0;
}