importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[] args){Scanner input =newScanner(System.in);int x = input.nextInt();// 点的横坐标int y = input.nextInt();// 点的纵坐标if(-1<= x && x <=1&&-1<= y && y <=1){// 如果点在正方形范围内System.out.print("yes");}else{// 否则,点不在正方形范围内System.out.print("no");}}}
五、C++程序
#include<iostream>usingnamespace std;intmain(){int x;// 点的横坐标int y;// 点的纵坐标
cin >> x;
cin >> y;if(-1<= x && x <=1&&-1<= y && y <=1)// 如果点在正方形范围内{
cout <<"yes";}else// 否则,点不在正方形范围内{
cout <<"no";}return0;}