51nod:2057:输出最小值:Python

72 阅读1分钟

www.51nod.com/Challenge/P…

n = int(input())  # 输入一个整数n,n表示整数的个数
a = []  # 新建一个空列表,用来保存这n个整数

for i in range(n):  # 循环n次
    a.append(int(input()))  # 每次往列表中添加一个整数

minValue = a[0]  # 先选取a[0]作为最小值

for ai in a:  # 依次从列表a中取出一个元素ai
    if minValue > ai:  # 如果当前这个元素ai更小
        minValue = ai  # 就把ai作为当前的最小值,即把ai赋给minValue

print(minValue)  # 输出最小值