2020-12-30

上一个博客的题目,改了一些

#
print("hello world")

import random

c = [random.randint(-9, 9) for i in range(0, random.randint(1, 100))]

i = 0

print(c)

a = len(c)

'''
d = [0] * a 

i = 0

if a==1:

    d[0] = 1

else:

    for i in range(0, a):
        
        if i==0 and c[i] > c[i+1]  or i==a - 1 and c[i] > c[i-1] or i > 0 and i < a - 1 and c[i] > c[i-1] and c[i] > c[i+1] : 
            
            d[i] = 1
 
print(d)

'''

d = [0] * a 

i = 0

if a == 1 :
    
    d[0]  = 1
    
else :
    
    n = [i for i in range(0, a) if i == 0 and c[i] > c[i + 1] or i == a - 1 and c[i] > c[i - 1] or i > 0 and i < a - 1 and c[i] > c[i - 1] and c[i] > c[i + 1] ]
     
    for j in n :

        d[j] = 1 
    
print(d)
 

你可能感兴趣的:(笔记)