题解 | #坐标移动#

坐标移动

http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29

额,python好像本来就可以检查是不是数字来着

command = input()
commands = command.split(';')

x = 0
y = 0
for command in commands:
  if len(command) > 1 and len(command) < 4:
    if command[0] == 'A' and command[1:].isnumeric():
      x -= int(command[1:])
    if command[0] == 'D' and command[1:].isnumeric():
      x += int(command[1:])
    if command[0] == 'S' and command[1:].isnumeric():
      y -= int(command[1:])
    if command[0] == 'W' and command[1:].isnumeric():
      y += int(command[1:])
print(f"{x},{y}")
全部评论

相关推荐

07-07 12:25
门头沟学院 Java
程序员牛肉:你这个智邮公司做的就是那个乐山市税务系统的服务吗?
点赞 评论 收藏
分享
机械打工仔:我来告诉你原因,是因为sobb有在线简历,有些HR为了快会直接先看在线简历,初步感觉不合适就不会找你要详细的了
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务