开发者

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

开发者 https://www.devze.com 2023-01-09 14:30 出处:网络
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 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

精彩评论

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

关注公众号