題目:
給出一個點的坐標,判斷點是否在要求的矩形范圍內
輸入格式:
第一行輸入點的坐標
第二行輸入矩形對角線的坐標
輸出格式:
判斷結果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://www.uj5u.com/qita/260529.html
標籤:其他
上一篇:Day6:可靠資料傳輸的原理
