const readline = require('readline-sync');
let str = `徐鑫,郑义,张胜于,赵杰,邓翔,黄飞翔,刘嘉豪,赵鑫勇,吴建磊,何静,孙妃燕,蔡梦蝶,秦阳,何正乾,赖运,刘朝先,赵玲,赵霖,李志超,袁会,陈建良,刘株汛,曾正旭`;
/**
* ?个三等奖
* ?个二等奖
* ?个一等奖
*/
//随机数函数
function random(max, min) {
if (max == undefined) {
max = min;
min = 0;
}
let number = Math.random(min, max);
let number1 = number * (max - min) + min;
return number1;
}
random();
let arr = str.split(',');
console.log('请输入一等奖人数');
let number =readline.question();
first(number);
console.log('请输入二等奖人数');
let number1 =readline.question();
first(number1);
console.log('请输入三等奖人数');
let number2 =readline.question();
first(number2);
function first(number) {
for (let i = 0; i < number; i++) {
let nuMer = parseInt(random(0, arr.length-1));
let name = arr[nuMer];
arr.splice(nuMer, 1);
console.log(name);
}
console.log(arr);
}
中奖人数随机
最新推荐文章于 2024-08-25 09:57:22 发布