题干描述比较复杂,其实题目挺简单的。
The discreption is hard to conprehension, well the question is a little simple.
Object_Oriented(面向对象解法):
#two dimension array
class tarray():
def __init__(self,x,y):
self.x=x
self.y=y
def if_init_suc(self):
if 0<=self.x<=9 and 0<=self.y<=9:return 0
else:return -1
def swapcoordinate(self,x1,y1,x2,y2):
if 0<=x1<self.x and 0<=y1<self.y and 0<=x2<self.x and 0<=y2<self.y:return 0
else:return -1
def rowin(self,row):
if 0<=row<self.x and self.x<9:return 0
else:return -1
def columnin(self,column):
if 0<=column<self.y and self.y<9:return 0
else:return -1
def pointin(self,px,py):
if 0<=px<self.x and 0<=py<self.y:return 0
else:return -1
while 1:
try:
m,n=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
row=int(input())
column=int(input())
px,py=map(int,input().split())
table=tarray(m,n)
print(table.if_init_suc())
print(table.swapcoordinate(x1,y1,x2,y2))
print(table.rowin(row))
print(table.columnin(column))
print(table.pointin(px,py))
except:break
京公网安备 11010502036488号