欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用js写三个数,让三个数从小到大排列

程序员文章站 2023-01-28 19:35:38
console.log('请输入三个数:'); let num1 = readline.question() - 0; let num2 = readline.question() - 0; let num3 = readline.question() - 0; let num4; if (num1 ......

console.log('请输入三个数:');
let num1 = readline.question() - 0;
let num2 = readline.question() - 0;
let num3 = readline.question() - 0;
let num4;
if (num1 > num2) {
num4 = num1;
num1 = num2;
num2 = num4;
}
if (num2 > num3) {
num4 = num2;
num2 = num3;
num3 = num4;
}
if (num1 > num3) {
num4 = num1;
num1 = num3;
num3 = num4;
}
console.log(num1 + '<' + num2 + '<' + num3);