#include <stdio.h>
struct point {
int x;
int y;
};
struct rectangle {
struct point p1;
struct point p2;
};
int main() {
struct point p1;
struct rectangle rec;
scanf("%d %d",&p1.x,&p1.y);
scanf("%d %d %d %d",&rec.p1.x,&rec.p1.y,&rec.p2.x,&rec.p2.y);
if(rec.p1.y > rec.p2.y && rec.p1.x < rec.p2.x){
if( (rec.p1.x <= p1.x && p1.x <= rec.p2.x) && (rec.p2.y <= p1.y && p1.y<= rec.p1.y)){
printf("YES");
}else{
printf("NO");
}
} else if(rec.p1.y < rec.p2.y && rec.p1.x < rec.p2.x){
if( (rec.p1.x <= p1.x && p1.x<= rec.p2.x) && (rec.p1.y <= p1.y && p1.y<= rec.p2.y)){
printf("YES");
}else{
printf("NO");
}
} else if(rec.p1.y < rec.p2.y && rec.p2.x < rec.p1.x){
if( (rec.p2.x <= p1.x && p1.x<= rec.p1.x) && (rec.p1.y <= p1.y && p1.y<= rec.p2.y)){
printf("YES");
}else{
printf("NO");
}
}else if(rec.p2.y < rec.p1.y && rec.p2.x < rec.p1.x) {
if ((rec.p2.x <= p1.x && p1.x<= rec.p1.x) && (rec.p2.y <= p1.y && p1.y<= rec.p1.y)) {
printf("YES");
} else {
printf("NO");
}
}
return 0;
}
c语言 点在矩形内
最新推荐文章于 2024-07-22 14:12:09 发布