题目:
给出一个点的坐标,判断点是否在要求的矩形范围内
输入格式:
第一行输入点的坐标
第二行输入矩形对角线的坐标
输出格式:
判断结果YES or NO
要求项:
输入矩形在可计入数字以内,输入数的类型为整数类型,用空格将其分开,目标矩形在X>0,Y>0第一象限内坐标所示位置
程序实例展示:
#include<stdio.h>
#include<math.h>
struct Point
{
int x;
int y;
};
struct Rectangle
{
struct Point p1 ;
struct Point p2 ;
};
struct Rectangle rec[2];
struct Point poi[1];
int main()
{
scanf_s("%d %d\n", &poi[0].x, &poi[0].y);
scanf_s("%d %d", &rec[0].p1.x, &rec[0].p1.y);
scanf_s("%d %d", &rec[1].p2.x, &rec[1].p2.y);
if (poi[0].x > rec[0].p1.x && poi[0].x<rec[1].p2.x && poi[0].y>rec[0].p1.y && poi[0].y < rec[1].p2.y)
printf("YES");
else
printf("NO");
return 0;
}
输出结果展示:
转载:https://blog.csdn.net/qq_50767141/article/details/113829340
查看评论