1
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>
2 < HTML >
3 < HEAD >
4 < TITLE > 报数测试 </ TITLE >
5 < META NAME ="Generator" CONTENT ="EditPlus" >
6 < META NAME ="Author" CONTENT ="" >
7 < META NAME ="Keywords" CONTENT ="" >
8 < META NAME ="Description" CONTENT ="" >
9 </ HEAD >
10
11 < BODY >
12 < div id ="debug" ></ div >
13 < script >
14 var debuginfo = document.getElementById( " debug " );
15
16 /*
17 *@method 报数函数(递归调用)
18 *@param arr{array} :参与人数组
19 *@param index{numbuer} :从几开始报数
20 *@param looptime{numbuer}[非调用参数] :循环次数
21 */
22 function baoshu(arr,index,looptime){
23 if ( ! looptime)looptime = 1 ;
24 if (arr.length == 1 ){alert( " 最后剩下: " + arr); return ;}
25 var _out = [];
26 debuginfo.innerHTML += " <br>第 " + looptime + " 轮------------------------------------ " ;
27 for ( var i = 0 ;i < arr.length;i ++ ,index ++ )
28 {
29 debuginfo.innerHTML += " <br> " + arr[i] + " : " + index + (index % 3 == 0 ? " 踢出 " : "" );
30 if (index % 3 != 0 )
31 {
32 _out.push(arr[i]);
33 }
34 }
35 setTimeout( function (){baoshu(_out,index, ++ looptime);}, 2000 );
36
37 }
38
39 /*
40 *@method 启动函数
41 *@param num{numbuer}[可选][@default:10] :参与人数
42 *@param start{numbuer}[可选][@default:1] :从几开始报数
43 */
44 function boot(num,start){
45 var start = start || 1 ;
46 var num = (num || 10 ) + 1 ;
47 var persons = [];
48 for ( var i = 1 ;i < num;i ++ )persons.push(i);
49 baoshu(persons, 1 );
50 }
51 boot();
52 </ script >
53 </ BODY >
54 </ HTML >
55
2 < HTML >
3 < HEAD >
4 < TITLE > 报数测试 </ TITLE >
5 < META NAME ="Generator" CONTENT ="EditPlus" >
6 < META NAME ="Author" CONTENT ="" >
7 < META NAME ="Keywords" CONTENT ="" >
8 < META NAME ="Description" CONTENT ="" >
9 </ HEAD >
10
11 < BODY >
12 < div id ="debug" ></ div >
13 < script >
14 var debuginfo = document.getElementById( " debug " );
15
16 /*
17 *@method 报数函数(递归调用)
18 *@param arr{array} :参与人数组
19 *@param index{numbuer} :从几开始报数
20 *@param looptime{numbuer}[非调用参数] :循环次数
21 */
22 function baoshu(arr,index,looptime){
23 if ( ! looptime)looptime = 1 ;
24 if (arr.length == 1 ){alert( " 最后剩下: " + arr); return ;}
25 var _out = [];
26 debuginfo.innerHTML += " <br>第 " + looptime + " 轮------------------------------------ " ;
27 for ( var i = 0 ;i < arr.length;i ++ ,index ++ )
28 {
29 debuginfo.innerHTML += " <br> " + arr[i] + " : " + index + (index % 3 == 0 ? " 踢出 " : "" );
30 if (index % 3 != 0 )
31 {
32 _out.push(arr[i]);
33 }
34 }
35 setTimeout( function (){baoshu(_out,index, ++ looptime);}, 2000 );
36
37 }
38
39 /*
40 *@method 启动函数
41 *@param num{numbuer}[可选][@default:10] :参与人数
42 *@param start{numbuer}[可选][@default:1] :从几开始报数
43 */
44 function boot(num,start){
45 var start = start || 1 ;
46 var num = (num || 10 ) + 1 ;
47 var persons = [];
48 for ( var i = 1 ;i < num;i ++ )persons.push(i);
49 baoshu(persons, 1 );
50 }
51 boot();
52 </ script >
53 </ BODY >
54 </ HTML >
55