开发者

How do I design an algorithm to find the biggest number in a list of numbers?

I also need 开发者_运维技巧to convert my answer into javascript code that displays the largest value.


alert(Math.max(13, 42, 86, 3, 25)); // 86


I guess you just need something on the lines of:

var mx = list[0];
for (i=1; i<length(list); i++)
    mx = Math.max(mx, list[i])

alert(mx)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜