用js写三个数,让三个数从小到大排列
程序员文章站
2023-12-24 17:00:57
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);