Informatics Olympiad: 1056: The relationship between point and square

1056: The relationship between points and squares

Time limit: 1000 ms Memory limit: 65536 KB
Number of submissions: 29647 Number of passes: 20111
[Title description]
There is a square, the coordinates of the four corners (x, y) are (1, -1), (1, 1) , (-1, -1), (-1, 1), x is the horizontal axis, and y is the vertical axis. Write a program to determine whether a given point is within the square (including the square boundary). If the point is inside the square, output yes, otherwise output no.

[Input]
Input a line, including two integers x, y, separated by a space, indicating coordinates (x, y).

[Output]
Output one line, if the point is in the square, output yes, otherwise output no.

【Input sample】
1 1
【Output sample】
yes

#include<iostream>
using namespace std;
int main()
{
    
    int x,y;
cin>>x>>y;
if(x>=(-1)&&x<=1&&y>=(-1)&&y<=1)
cout << "yes" << endl;
else
cout << "no" << endl;
return 0;
}

Guess you like

Origin blog.csdn.net/qq_51082388/article/details/112796858