有用请采纳
#include<iostream>
#include<cmath> // 使用sqrt
using namespace std;
class Point{
private:
int x, y;
public:
Point(double x, double y);
void printPoint();
void calculateDistance(double otherX, double otherY);
Point symmetryPoint();
void judgeInCircle(double p, double q, double r);
};
Point::Point(double x, double y){
this->x = x;
this->y = y;
}
void Point::printPoint(){
cout << this->x << " " << this->y << endl;
}
void Point::calculateDistance(double otherX, double otherY){
double distance;
distance = sqrt((otherX - this->x) * (otherX - this->x) + (otherY - this->y) * (otherY - this->y));
printf("%.8lf\n", distance);
}
Point Point::symmetryPoint(){
cout << -this->x << " " << -this->y << endl;
}
void Point::judgeInCircle(double p, double q, double r){
double distance; //圆心到点的距离
distance = sqrt((p - this->x) * (p - this->x) + (q - this->y) * (q - this->y));
double judgeRange = 0.00001;
if(fabs(distance) < r)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
int main(){
double x, y;
int choose, num;
cin >> x >> y;
Point point = Point(x, y);
double otherX, otherY;
double circleX, circleY, circleR;
cin >> choose;
for (int i = 0; i < choose; i++){
cin >> num;
switch(num){
case 1:
point.printPoint();
break;
case 2:
cin >> otherX >> otherY;
point.calculateDistance(otherX, otherY);
break;
case 3:
point.symmetryPoint();
break;
case 4:
cin >> circleX >> circleY >> circleR;
point.judgeInCircle(circleX, circleY, circleR);
break;
default:
break;
}
}
}