如何在不使用python中的内置函数的情况下在列表中找到最大值?

时间:2014-10-05 01:14:50

标签: python max lis

我想创建一个能够在数字列表中打印最大值的函数。

1 个答案:

答案 0 :(得分:-1)

我不知道python,但伪代码看起来像这样

max = –2147483648

for each integer n in collection
   if n > max
      max = n

循环遍历集合中的每个数字。如果数字(n)大于先前的最大值,则将最大值设置为等于n。