-
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Little to Big</title> </head> <body> <script type="text/javascript"> var num1 = +prompt("请输入第一个整数:"); var num2 = +prompt("请输入第二个整数:"); var num3 = +prompt("请输入第三个整数:"); var biggest; var middle; var little; if (num1 > num2) { if(num2 > num3) { biggest = num1; middle = num2; little = num3; } else { if(num1 > num3) { biggest = num1; middle = num3; } else { biggest = num3; middle = num1; } little = num2; } } else { if(num1 > num3) { biggest = num2; middle = num1; little = num3; } else { if(num2 > num3) { biggest = num2; middle = num3; } else { biggest = num3; middle = num2; } little = num1; } } alert(little+" < "+middle+" < "+biggest); document.write(little+" < "+middle+" < "+biggest); </script> </body> </html>