C语言判断一个点与圆的位置关系-创新互联
C语言判断一个点与圆的位置关系
分享标题:C语言判断一个点与圆的位置关系-创新互联
URL链接:http://azwzsj.com/article/csgseo.html
#includetypedef struct
{float x;
float y;
}POINT;
int main(int argc, char *argv[])
{float lfv_rad;
float lfv_dis;
int liv_quit = 0;
POINT lsv_point1, lsv_point2;
printf("请输入圆心的坐标:\n");
scanf("%f,%f", &lsv_point1.x, &lsv_point1.y);
printf("请输入圆的半径\n");
scanf("%f", &lfv_rad);
printf("圆心为(%0.2f,%0.2f),半径为%0.2f的圆已经确定\n", lsv_point1.x, lsv_point1.y, lfv_rad);
printf("现在请输入需要判断的坐标:\n");
scanf("%f,%f", &lsv_point2.x, &lsv_point2.y);
lfv_dis = (lsv_point2.x - lsv_point1.x) * (lsv_point2.x - lsv_point1.x) + (lsv_point2.y - lsv_point1.y) * (lsv_point2.y - lsv_point1.y);
if(lfv_dis == (lfv_rad * lfv_rad))
{printf("在圆上\n");
}
else if(lfv_dis >= (lfv_rad * lfv_rad))
{printf("在圆外\n");
}
else
{printf("在园内\n");
}
return 0;
}
结果:
C语言编程学习笔记
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
分享标题:C语言判断一个点与圆的位置关系-创新互联
URL链接:http://azwzsj.com/article/csgseo.html