C++ 判断两个圆是否有交集
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include <math.h>
#include <easyx.h>
#include <graphics.h>
typedef struct T_circle
{
int x; //x轴坐标
int y;//Y轴坐标
int r; //圆的半径
}yuan;
void panduan(yuan test1, yuan test2)
{
double d;//定义(圆心的距离)
d = sqrt((test1.x - test2.x)*(test1.x - test2.x) + (test1.y - test2.y)*(test1.y - test2.y));
if (d > test1.r + test2.r)
{
printf("没有交集\n");
}
else if (d <= test1.r + test2.r)
{
printf("相切/交\n");
}
}
void draw(yuan test1,yuan test2)
{
initgraph(, ,SHOWCONSOLE);
BeginBatchDraw();
cleardevice();
setlinecolor(RED);
circle(test1.x, test1.y, test1.r);
circle(test2.x, test2.y, test2.r);
EndBatchDraw();
system("pause");
closegraph();
}
//首先要求出两个圆心的距离,公式为:d=√[(x2-x1)²+(y2-y1)²] 这里要用到math.h头文件sqrt
int main()
{
yuan circle1 = { ,, }; //定义一个圆
yuan circle2 = { ,, }; //定义一个圆
panduan(circle1, circle2);
draw(circle1, circle2);
return ;
}

C++ 判断两个圆是否有交集的更多相关文章
- 实验12:Problem D: 判断两个圆之间的关系
Home Web Board ProblemSet Standing Status Statistics Problem D: 判断两个圆之间的关系 Problem D: 判断两个圆之间的关系 T ...
- mysql判断两个时间段是否有交集
//判断两个时间段是否有交集 private function checkTimeCross($start_time,$end_time){ $sql ) AND ((start_time > ...
- js判断两个时间段是否有交集
//判断两个时间是否有交集 function isDateIntersection(start1, end1, start2, end2) { var startdate1 = new Date(st ...
- java 判断两个时间段是否有交集
/* 开始时间 */ Date leftStartDate = feesPreferential.getPreferentialStartTime(); /* 结束时间 */ Date leftEnd ...
- java 判断两个时间段是不是有交集
如上图:X Y Z 分别为传来的开始时间可能位于数据库中时间段的位置. X有三种可能 即传来的开始时间为与数据可中某条数据的开始位置! 这样他的结束时间就有三种可能 1.位于 ...
- sql语句判断两个时间段是否有交集
场景: 数据库有有两个字段.开始时间<startTime>,和结束时间<endTime>,指定一个时间段(a,b),a表示开始时间,b表示结束时间.看数据库中有没有与(a,b ...
- c# 判断两个集合是否有交集
/// <summary> /// 判断是否有交集 /// </summary> /// <typeparam name="T"></ty ...
- sql 判断两个时间段是否有交集
本文转自CSDN 链接地址:http://blog.csdn.net/dasihg/article/details/8450195 时间段:starttime_1到endtime_1,starttim ...
- php 判断两个时间段是否有交集
一开始,没啥思路,全靠百度,记录一下哈 public function demo(){ //例子 $astart = strtotime("1995-06-16 12:00:00" ...
随机推荐
- flink 基本原理
state状态操作 https://ci.apache.org/projects/flink/flink-docs-release-1.8/concepts/programming-model.htm ...
- 响应式WEB页面开发实践
转自:https://github.com/markyun/My-blog/issues/27 最近得到一个新任务单,让我用一套页面适应所有主流终端(Android.iPhone.iPad.PC),而 ...
- LG_3457_[POI2007]POW-The Flood
题目描述 Description 你手头有一张该市的地图.这张地图是边长为 m∗n 的矩形,被划分为m∗n个1∗1的小正方形.对于每个小正方形,地图上已经标注了它的海拔高度以及它是否是该市的一个组成部 ...
- (转)假如没有OI By Vani
假如没有OI ...
- keepalive笔记之二:keepalive+nginx(自定义脚本实现,上述例子也可以实现)
keepalive的配置文件 ! Configuration File for keepalived global_defs { notification_email { acassen@firewa ...
- IOUtils和FileUtils的学习笔记
pom文件导入依赖import org.apache.commons.io.FileUtils; <dependency> <groupId>commons-io</gr ...
- TensorFlow_Faster_RCNN中demo.py的运行(CPU Only)
GitHub项目地址,https://github.com/endernewton/tf-faster-rcnnTensorflow Faster RCNN for Object Detection. ...
- ES:PB级别的大索引如何设计
一.单个大索引的缺陷 如果每天亿万+的实时增量数据呢,基于以下几点原因,单个索引是无法满足要求的: 1.存储大小限制维度 单个分片(Shard)实际是 Lucene 的索引,单分片能存储的最大文档数是 ...
- OpenGL ES 学习笔记 - Overview - 小旋的博客
移动端图形标准中,目前 OpenGL ES 仍然是比较通用的标准(Vulkan 则是新一代),这里新开一个系列用于记录学习 OpenGL ES 的历程,以便查阅理解. OverView OpenGL ...
- Y事业部打造一体化质量管理平台
互联网企业质量管理的困惑 作为互联网时代的互联网企业,我们的研发模式和传统模式相比,最显著的不同在于发布节奏加快了,这个加快不是快了10%,20%,50%,而是加快了几倍,甚至几十倍,上百倍.面对加快 ...