Description

定义一个Point类和Circle类,用于判断给定的一系列的点是否在给定的圆内。

其中,Point类:

1.有2个成员x和y,分别为其横坐标和纵坐标;1个静态成员numOfPoints,用于计算生成的点的个数。

2.具有构造函数、析构函数和拷贝构造函数,具体格式输出根据样例自行判断。

3. 具有静态方法int getNumOfPoints(),用于返回numOfPoints的值。

4. 具有int getX()和int getY()方法,用于获取横坐标和纵坐标。

Circle类:

1. 拥有Point类的对象center,表示圆心坐标。拥有radius对象,表示圆的半径;1个静态成员numOfCircles,用于指示生成了多少个圆对象。

2. 具有构造函数、析构函数和拷贝构造函数,具体格式根据样例自行判断。

3.具有静态方法int getNumOfCircles(),返回numOfCircles的值。

4. 具有getCenter()方法,返回圆心坐标。注意:根据输出结果判断返回值类型。

5. 具有bool pointInCircle(Point &)方法,用于判断给定的点是否在当前圆内。是则返回true,否则返回false。

Input

输入分多行。

第一行M>0,表示有M个测试用例。

每个测试用例又包括多行。第1行包含3个整数,分别为一个圆的横坐标、纵坐标和半径。第2行N>0,表示之后又N个点,每个点占一行,分别为其横坐标和纵坐标。

所有输入均为整数,且在int类型范围内。

Output

输出见样例。注意:在圆的边上的点,不在圆内。

Sample Input

2

0 0 10

3

2 2

11 11

10 0

1 1 20

3

2 2

1 1

100 100

Sample Output

The Point (0, 0) is created!Now, we have 1 points.

The Point (1, 1) is created! Now, we have 2 points.

A circle at (1, 1) and radius 1 is created! Now, we have 1 circles.

We have 2 points and 1 circles now.

The Point (0, 0) is created! Now, we have 3 points.

A Point (0, 0) is copied! Now, we have 4 points.

A Point (0, 0) is copied! Now, we have 5 points.

A circle at (0, 0) and radius 10 is created! Now, we have 2 circles.

A Point (0, 0) is erased! Now, we have 4 points.

The Point (2, 2) is created! Now, we have 5 points.

(2, 2) is in the circle at (0, 0).

The Point (11, 11) is created! Now, we have 6 points.

(11, 11) is not in the circle at (0, 0).

The Point (10, 0) is created! Now, we have 7 points.

(10, 0) is not in the circle at (0, 0).

A Point (0, 0) is erased! Now, we have 6 points.

A circle at (0, 0) and radius 10 is erased! Now, we have 1 circles.

A Point (0, 0) is erased! Now, we have 5 points.

The Point (1, 1) is created! Now, we have 6 points.

A Point (1, 1) is copied! Now, we have 7 points.

A Point (1, 1) is copied! Now, we have 8 points.

A circle at (1, 1) and radius 20 is created! Now, we have 2 circles.

A Point (1, 1) is erased! Now, we have 7 points.

The Point (2, 2) is created! Now, we have 8 points.

(2, 2) is in the circle at (1, 1).

The Point (1, 1) is created! Now, we have 9 points.

(1, 1) is in the circle at (1, 1).

The Point (100, 100) is created! Now, we have 10 points.

(100, 100) is not in the circle at (1, 1).

A Point (1, 1) is erased! Now, we have 9 points.

A circle at (1, 1) and radius 20 is erased! Now, we have 1 circles.

A Point (1, 1) is erased! Now, we have 8 points.

We have 8 points, and 1 circles.

A circle at (1, 1) and radius 1 is erased!Now, we have 0 circles.

A Point (1, 1) is erased! Now, we have 7 points.

A Point (0, 0) is erased! Now, we have 6 points.

HINT

#include<iostream>
using namespace std;
class Point
{friend class Circle;
private:int x,y;static int numOfPoints;
public:Point(int a=0,int b=0):x(a),y(b){numOfPoints++;cout<<"The Point ("<<x<<", "<<y<<") is created! Now, we have "<<numOfPoints<<" points."<<endl;}Point(const Point&p){numOfPoints++;x=p.x;y=p.y;cout<<"A Point ("<<x<<", "<<y<<") is copied! Now, we have "<<numOfPoints<<" points."<<endl;}static int getNumOfPoints(){return numOfPoints;}int getX(){return x;}int getY(){return y;}~Point(){numOfPoints--;cout<<"A Point ("<<x<<", "<<y<<") is erased! Now, we have "<<numOfPoints<<" points."<<endl;}
};
class Circle
{
private:Point center;int radius;static int numOfCircles;
public:Circle(int a,int b,int c):center(a,b),radius(c){numOfCircles++;cout<<"A circle at ("<<center.x<<", "<<center.y<<") and radius "<<radius<<" is created! Now, we have "<<numOfCircles<<" circles."<<endl;}Circle(Point p,int r):center(p),radius(r){numOfCircles++;cout<<"A circle at ("<<center.x<<", "<<center.y<<") and radius "<<radius<<" is created! Now, we have "<<numOfCircles<<" circles."<<endl;}Circle(const Circle &c){numOfCircles++;center.x=c.center.x;center.y=c.center.y;radius=c.radius;cout<<"A circle at ("<<center.x<<", "<<center.y<<") and radius "<<radius<<" is created! Now, we have "<<numOfCircles<<" circles."<<endl;}static int getNumOfCircles(){return numOfCircles;}Point &getCenter(){return center;}~Circle(){numOfCircles--;cout<<"A circle at ("<<center.x<<", "<<center.y<<") and radius "<<radius<<" is erased! Now, we have "<<numOfCircles<<" circles."<<endl;}bool pointInCircle(Point &p){if((p.x-center.x)*(p.x-center.x)+(p.y-center.y)*(p.y-center.y)<radius*radius) return true;else return false;}};
int Point::numOfPoints=0;
int Circle::numOfCircles=0;int main()
{int cases,num;int x, y, r, px, py;Point aPoint(0,0), *bPoint;Circle aCircle(1,1,1);cin>>cases;cout<<"We have "<<Point::getNumOfPoints()<<" points and "<<Circle::getNumOfCircles()<<" circles now."<<endl;for (int i = 0; i < cases; i++){cin>>x>>y>>r;bPoint = new Point(x,y);Circle circle(*bPoint, r);cin>>num;for (int j = 0; j < num; j++){cin>>px>>py;if (circle.pointInCircle(*(new Point(px, py)))){cout<<"("<<px<<", "<<py<<") is in the circle at (";cout<<circle.getCenter().getX()<<", "<<circle.getCenter().getY()<<")."<<endl;}else{cout<<"("<<px<<", "<<py<<") is not in the circle at (";cout<<circle.getCenter().getX()<<", "<<circle.getCenter().getY()<<")."<<endl;}}delete bPoint;}cout<<"We have "<<Point::getNumOfPoints()<<" points, and "<<Circle::getNumOfCircles()<<" circles."<<endl;return 0;
}

SDUST 点在圆内吗?相关推荐

  1. Algorithm:C++语言实现之概率算法相关问题(计算机中的概率事件、C语言中的随机事件、产生二维随机数、圆内均匀取点)

    Algorithm:C++语言实现之概率算法相关问题(计算机中的概率事件.C语言中的随机事件.产生二维随机数.圆内均匀取点) 目录 一.概率 1.计算机中的概率事件 1.1.C语言中的随机事件 1.2 ...

  2. Java黑皮书课后题第3章:**3.29(几何:两个圆)编写程序,提示用户输入两个圆的中心坐标和各自的半径值,然后判断圆是在第一个圆内,还是和第一个圆重叠

    **3.29(几何:两个圆)编写程序,提示用户输入两个圆的中心坐标和各自的半径值,然后判断圆是在第一个圆内,还是和第一个圆重叠 题目 题目概述 运行示例 代码 题目 题目概述 **3.29(几何:两个 ...

  3. Java黑皮书课后题第3章:**3.22(几何:点是否在圆内)编写程序,提示用户输入一个点(x,y),然后检查这个点是否在以(0,0)为圆心、半径为10的圆内

    **3.22(几何:点是否在圆内)编写程序,提示用户输入一个点(x,y),然后检查这个点是否在以(0,0)为圆心.半径为10的圆内 题目 题目概述 课本提示与举例.运行示例 破题 代码 两个浮点数的比 ...

  4. 有限覆盖定理证明区间套_圆内整点问题的开普勒猜想证明,关于圆内整点问题误差项的估值E(r)=1-x,x=sin(nx)...

    将圆内整点问题视为格点对于圆的最大密度填充,用开普勒猜想证明,二维平面的 圆内整点问题误差项的估值 ,圆半径的格点数表示 , , 延拓至椭圆内整点问题结合皮克定理可应用于椭圆周长计算,当短长轴之比趋于 ...

  5. 判断一个点是否在指定的圆内

    public static bool IsPointInCircle(myPoint p, myCircle circle)         {             //到圆心的距离 是否大于半径 ...

  6. Problem C: 点在圆内吗?

    Description 定义一个Point类和Circle类,用于判断给定的一系列的点是否在给定的圆内. 其中,Point类: 1.有2个成员x和y,分别为其横坐标和纵坐标:1个静态成员numOfPo ...

  7. 设计一个类代表二维空间的一个点,设计一个类代表二维空间的一个圆。要求两个成员变量。一个是圆心,一 个是半径,提供计算面积的方法。为上述Cricle类添加一个方法,计算一个点(Point)是否在圆内

    (1) 设计一个类代表二维空间的一个点 (2) 设计一个类代表二维空间的一个圆.要求两个成员变量.一个是圆心,一 个是半径,提供计算面积的方法. (3) 为上述Cricle类添加一个方法,计算一个点( ...

  8. 【C语言】判断二维空间中的点,是否在圆内(输出:该点在圆内、该点在圆上、该点在圆外)。 允许的误差为1e-6.

    前言 判断二维空间中的点,是否在圆内(输出:该点在圆内.该点在圆上.该点在圆外). 允许的误差为1e-6. **输入格式要求:"%f,%f" "%f" &quo ...

  9. 三个点在同一个半圆的概率_圆内任取三点/四点在同一半圆内的概率是多少?...

    大家的做法好像都有点麻烦--我用高中(有点竞赛?)的方法解答. 设四个点为 C₁ , C₂ , C₃ , C₄ 分别位于直径 A₁B₁ , A₂B₂ , A₃B₃ , A₄B₄ 上.不妨设四条直径各不 ...

最新文章

  1. python常见的数据类型_Python常见数据类型及操作
  2. 使用 ExtJs Extender Controls 遇到的第一个错误
  3. 那些永不消逝的进程 (转)
  4. PyInstaller打包exe,打包出来的可执行程序在触屏版win10家庭版系统下报错Colud not find QtWebEngineProcess.exe
  5. R 操作矩阵和计算SVD的基本操作记录
  6. Jqurey学习笔记---3、jQuery 选择器
  7. AMD推Radeon HD 7790显卡 性价比突出下月开卖
  8. 自定义DataAnnotations
  9. h5py group_人工智能驱动的零售:H&M Group如何做到
  10. lisp princ详解_LISP教程
  11. GMP法规附录《计算机化系统》那些事儿
  12. c# 检测中英输入法_C# Winform 中如何获取本机安装输入法,并设置为默认输出语言,如何打开搜狗输入法和手写板...
  13. 手机遇到性能BUG怎么破?
  14. 【毕业设计选题】2022通信工程毕业设计题目推荐大全
  15. android 挖孔屏适配_使用Flexible实现手淘H5页面的终端适配
  16. goss - 一个简洁的 golang 对象存储库
  17. python学习——图形界面
  18. 【推荐算法 学习与复现】-- 逻辑回归算法族 -- LR
  19. 一份数据科学“必备”的数学基础清单
  20. 区块链100篇之哈希算法

热门文章

  1. 如何将stl模型,转换成点云文件)
  2. 陶泓达:本周最新走势分析及操作建议
  3. Macsome iTunes Converter for Mac(DRM移除和音乐转换器)3.5.0
  4. 多维标度法(MDS,Multidimensional Scaling)及普氏分析(Procrustes Analysis)在人体姿态关节点上的简单示例(python)
  5. 真正解决vbox不能为虚拟电脑打开一个新任务的解决方法
  6. 全球最大同性交友网站的所有用户密码都无法登录!!!
  7. Linux系列 | Ubuntu 各版本号和名称对照【转】
  8. 字符串匹配 KMP算法
  9. javascript Array系列函数之14:every函数
  10. windows 程序设计 第三章读书笔记(上)