考察知识点:(难度☆☆)
循环和分支语句的综合使用.
代码示例:
m = input()
list = m.split(",")
total = 0
for i in range(0, int(len(list))-1):
a = int(list[i])
b = int(list[i+1])
if a * b < 0:
# 上楼
if b - a >= 1:
total += (b-a-1) * 1
# 下楼
elif b - a < 0:
total += (a-b-1) * 0.3
else:
# 上楼
if b - a >= 1:
total += (b-a) * 1
# 下楼
elif b - a < 0:
total += (a-b) * 0.3
print(total)