现在的位置: 首页 > 综合 > 正文

javascript随机数

2013年06月19日 ⁄ 综合 ⁄ 共 228字 ⁄ 字号 评论关闭
function Random( num_first,num_last ){       //输出指定范围内的随机数的随机整数
	switch( arguments.length ){
		case 1 : return parseInt( Math.random() * num_first + 1 );                    
		case 2 : return parseInt( Math.random() * ( num_last - num_first + 1 ) + num_first );
		default : return 0;
	};
};
Random(1,100)

抱歉!评论已关闭.