let input1 = [11,3,7,2,9,10];
let input2 = [-2,-11,-100,3];
function secondMinimum(values){
min = Number.MAX_SAFE_INTEGER;
sndMin = Number.MAX_SAFE_INTEGER;
for (value of values) {
if (value != min) {
if(value < min) {
sndMin = min;
min = value;
}
else if (value < sndMin){
sndMin = value;
}
}
}
console.log(sndMin);
}
secondMinimum(input1);
secondMinimum(input2);
javascript:查找倒数第二小的数
最新推荐文章于 2024-03-11 09:49:12 发布