【发布时间】:2013-11-30 09:56:07
【问题描述】:
我正在尝试使用这个 while 循环来遍历我的数组以找到我的数组中的最小数字。想法?
array_2=[]
test_scores=[75, 100, 85, 65, 84, 87, 95, 99, 200]
while test_scores.count > 1
if test_scores[1] > test_scores[0]
array_2.push(test_scores[0])
test_scores.count
elsif
total_scores[0] < test_scores[1]
array_2.push(test_scores[1])
test_scores.count
elsif
test_scores.count==1
break
end
end
【问题讨论】:
标签: ruby arrays while-loop