201604-1 CCF认证考试 折点数 Python版

tech2022-08-17  134

满分答案:

n = int(input()) price = [0 for i in range(n)] price = input().split() num = 0 for i in range(n): price[i] = int(price[i]) for i in range(n-2): if price[i] > price[i+1] and price[i+1] < price[i+2]: num = num +1 if price[i] < price[i+1] and price[i+1] > price[i+2]: num = num +1 print(num)

 

最新回复(0)