http://acm.hdu.edu.cn/showproblem.php?pid=4815 Description A crowd of little animals is visiting a mysterious laboratory � The Deep Lab of SYSU. “Are you surprised by the STS (speech to speech) technology of Microsoft Research and the cat face recogn
明明想在学校中请一些同学一起做一项问卷调查,为了实验的客观性,他先用计算机生成了N个1到1000之间的随机整数(N≤1000),对于其中重复的数字,只保留一个,把其余相同的数去掉,不同的数对应着不同的学生的学号.然后再把这些数从小到大排序,按照排好的顺序去找同学做调查.请你协助明明完成“去重”与“排序”的工作. Input Param n 输入随机数的个数 inputArray n个随机整数组成的数组 Return Value OutputArray
前言 上午处理个需求需要从一个总数组中随机取出不同的元素.共使用两个方法.第一种方法较常规,经测试有bug,数据量大以后随机几次返回的对象直接是function而不是object. 当然简单数据类型应该没有这个问题.第二种是使用洗牌算法,亲测有效. 一.常规算法 /** 从数组中随机抽取数据 2016-09-09 **/ function getArrItem(arr, num) { var temp_array = new Array(); for (var index in arr) { t