1.使用函数完成给定的三个数字,并按照从大到小排列
2.(1)数据获取
(2)如何进行判断大小
3.(1)
var one=prompt("请输入第一个数字")
one=parseInt(one)
var two=prompt("请输入第二个数字")
two=parseInt(two)
var three=prompt("请输入第三个数字")
three=parseInt(three)
var max=0
var min=0
(2)
function number(){
if(one<two && one<three){
min=one
if(two<three){
max=three
}else{
max=two
}
document.write("最大值:"+max+"最小值:"+min)
}
if(two<one && two<three){
min=two
if(one<three){
max=three
}else{
max=one
}
document.write("最大值:"+max+"最小值:"+min)
}
if(three<one && three<two){
min=three
if(one<two){
max=two
}else{
max=one
}
document.write("最大值:"+max+"最小值:"+min)
}
}
(4)如何将三个最大值最小值进行判断
(5)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
function number(){
if(one<two && one<three){
min=one
if(two<three){
max=three
}else{
max=two
}
document.write("最大值:"+max+"最小值:"+min)
}
if(two<one && two<three){
min=two
if(one<three){
max=three
}else{
max=one
}
document.write("最大值:"+max+"最小值:"+min)
}
if(three<one && three<two){
min=three
if(one<two){
max=two
}else{
max=one
}
document.write("最大值:"+max+"最小值:"+min)
}
// document.write("最大值:"+max+"最小值:"+min)
}
var one=prompt("请输入第一个数字")
one=parseInt(one)
var two=prompt("请输入第二个数字")
two=parseInt(two)
var three=prompt("请输入第三个数字")
three=parseInt(three)
var max=0
var min=0
number()
</script>
</head>
<body>
</body>
</html>