input three integer numbers a,b and c with comma,then onput themin ascending order

来源:百度知道 编辑:UC知道 时间:2024/06/14 09:51:16
RT

//方法很笨,很实用,还有种情况总结慢慢写,呵呵
<html>
<head>
<script type="text/javascript">

function disp_prompt()
{
var f=prompt("Input first int","1");
var s=prompt("Input second int","2");
var t=prompt("Input third int","3");
var newArr = new Array();
if (f < s)
{
if (s < t) {
newArr.push(f);
newArr.push(s);
newArr.push(t);

}
else{
if (f < t) {
newArr.push(f);
newArr.push(t);
newArr.push(s);
}
else{
newArr.push(t);
newArr.push(f);
newArr.push(s);
}
}
}

for (x in newArr) {
document.write(newArr[x]+"<br />");
}
}

</script>
</head>
<body>

&