`
passionke
  • 浏览: 21399 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

chenlin吃不了饭了1

 
阅读更多

# $language = "Python"
# $interface = "1.0"

# Connect to a telnet server and automate the initial login sequence.
# Note that synchronous mode is enabled to prevent server output from
# potentially being missed.


def move_right(temp_x,temp_y,matrix,result):
    flag = 0
    while(temp_y<3 and matrix[temp_x][temp_y]==0):
        flag = flag + 1
        matrix[temp_x][temp_y] = result
        result = result + 1
        temp_y = temp_y + 1
        if matrix[temp_x][temp_y]!=0:
            temp_x = temp_x + 1
            temp_y = temp_y - 1
            break
    if flag == 0:
        return
    else:
        move_down(temp_x,temp_y,matrix,result)

def move_down(temp_x,temp_y,matrix,result):
    flag = 0
    while(temp_x<3 and matrix[temp_x][temp_y]==0):
        flag = flag + 1
        matrix[temp_x][temp_y] = result
        temp_x = temp_x + 1
        result = result + 1
        if matrix[temp_x][temp_y]!=0:
            temp_x = temp_x - 1
            temp_y = temp_y - 1
            break
    if flag == 0:
        return
    else:
        move_left(temp_x,temp_y,matrix,result)

def move_left(temp_x,temp_y,matrix,result):
    flag = 0
    while(temp_y>0 and matrix[temp_x][temp_y]==0):
        flag = flag + 1
        matrix[temp_x][temp_y] = result
        result = result + 1
        temp_y = temp_y - 1
    if flag ==0:
        return
    else:
        move_up(temp_x,temp_y,matrix,result)

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics