![]()
<script type="text/javascript">
function Sort(t, num)
{ if (num>1)
{ Max(t,num);
Sort(t,num-1);
}
}
function Max(t, num)
{ var w;
if (num<2) return;
Max(t,num-1);
if (t[num-2]>t[num-1])
{ w= t[num-2];
t[num-2]= t[num-1];
t[num-1]= w;
}
}
</script>
</head>
<body>
<script type="text/javascript">
var t= new Array();
for(i=0; i<5; i++)
t.push(Math.floor(Math.random() * 100)+1);
Sort(t, 5);
document.write(t + "<br>");
</script>
|
for(i=0; i<5; i++)
t.push(Math.floor(Math.random() * 100)+1);
|
Sort(t, 5); document.write(t + "<br>"); </script> |
function Max(t, num)
{ var w;
if (num<2) return;
Max(t,num-1);
|
if (t[num-2]>t[num-1])
{ w= t[num-2];
t[num-2]= t[num-1];
t[num-1]= w;
}
|
![]()