#include<iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;
class Point
{ double x; double y;
public:
void p(double x,double y)
double r() {return sqrt(x*x+y*y);}
double theta() {return atan(y/x);}
double distance (const Point& p) {return sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));}
Point relative(const Point &p)
{return sqrt( (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));}
bool is above left(const Point &p)
{double x1,x2,y1,y2;
if(x1<x2||y1>y2)
cout<<"0";
else
cout<<"p1不在p2左上方";
cout<<endl;
return 0;
}
};
void Point::print()
{cout<<"x="<<x<<" y="<<y<<endl;}
int main()
{
Point p1,p2(3,4);
cout<<"p1:";p1.print();
cout<<"p2:";p2.print();
cout<<"P2 的极坐标的极半径:"<<p2.r()<<endl;
cout<<"p1到p2的距离:"<<p1.distance(p2)<<endl;
Point p3=p1.relative(p2);
p3.print();
cout<<"p1是否在点p2的左上方:"<<p1. is_above_left(p2)<<endl;
return 0;
}
#include<math.h>
#include<stdlib.h>
using namespace std;
class Point
{ double x; double y;
public:
void p(double x,double y)
double r() {return sqrt(x*x+y*y);}
double theta() {return atan(y/x);}
double distance (const Point& p) {return sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));}
Point relative(const Point &p)
{return sqrt( (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));}
bool is above left(const Point &p)
{double x1,x2,y1,y2;
if(x1<x2||y1>y2)
cout<<"0";
else
cout<<"p1不在p2左上方";
cout<<endl;
return 0;
}
};
void Point::print()
{cout<<"x="<<x<<" y="<<y<<endl;}
int main()
{
Point p1,p2(3,4);
cout<<"p1:";p1.print();
cout<<"p2:";p2.print();
cout<<"P2 的极坐标的极半径:"<<p2.r()<<endl;
cout<<"p1到p2的距离:"<<p1.distance(p2)<<endl;
Point p3=p1.relative(p2);
p3.print();
cout<<"p1是否在点p2的左上方:"<<p1. is_above_left(p2)<<endl;
return 0;
}