n = int(input()) list1 = list(map(int,input().split())) num = 0 for i in range(1, n-1): if (list1[i-1] > list1[i] and (list1[i+1] > list1[i])) or\ (list1[i-1] < list1[i] and (list1[i+1] < list1[i])): num = num + 1 print(num)
CCF python 折点计数
阅读 80
2022-01-12
n = int(input()) list1 = list(map(int,input().split())) num = 0 for i in range(1, n-1): if (list1[i-1] > list1[i] and (list1[i+1] > list1[i])) or\ (list1[i-1] < list1[i] and (list1[i+1] < list1[i])): num = num + 1 print(num)
相关推荐
精彩评论(0)