牛客网-迷路的牛牛 Python

N = int(input())    #表示转方向的次数
direction = list(input())   #表示方向
temp = "N"
for i in range(N):
    if(temp=="N"):
        if(direction[i]=='L'):
            temp='W'
        else:
            temp='E'
    elif(temp=="E"):
        if(direction[i]=='L'):
            temp='N'
        else:
            temp='S'
    elif(temp=='S'):
        if(direction[i]=='L'):
            temp='E'
        else:
            temp='W'
    else:
        if(direction[i]=='L'):
            temp='S'
        else:
            temp='N'
print(temp)

 

你可能感兴趣的:(程序设计(CCF,LeetCode,牛客网))