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


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);


posted @ 2018-05-19 13:35  YKmaster  阅读(4278)  评论(0编辑  收藏  举报