点和正方形的关系
题目描述
有一个正方形,四个角的坐标 ( x , y ) (x,y) (x,y) 分别是 ( 1 , − 1 ) (1,-1) (1,−1)、 ( 1 , 1 ) (1,1) (1,1)、 ( − 1 , − 1 ) (-1,-1) (−1,−1)、 ( − 1 , 1 ) (-1,1) (−1,1), x x x 是横轴, y y y 是纵轴。写一个程序,判断一个给定的点是否在这个正方形内(包括正方形边界)。
输入格式
输入一行,包括两个整数 x , y x,y x,y,以一个空格分开,表示坐标 ( x , y ) (x,y) (x,y)。
输出格式
输出一行,如果点在正方形内,则输出 yes
,否则输出 no
。
样例 #1
样例输入 #1
1 1
样例输出 #1
yes
代码内容
// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//队列
// #include <queue>//堆/优先队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll x,y;
cin>>x>>y;
if(-1<=x&&x<=1&&-1<=y&&y<=1) puts("yes");
else puts("no");
return 0;
}