再对比一下相应的javascript代码

回答: 谢谢。已收藏到google doc里。bangbang98142012-06-20 16:43:41

function countingoff(count, steps) {

    var people = []

    while (count) { people.unshift(count--)}

    var idx = 0

    while (people.length) {

        idx = (idx + steps - 1)%people.length

        console.log("removed: #", people.splice(idx, 1)[0], ", left: ", people)

    }

}

// example

countingoff(25, 7)

所有跟帖: 

稍微改了一下,更漂亮些。 -柯西- 给 柯西 发送悄悄话 柯西 的博客首页 (580 bytes) () 06/20/2012 postreply 23:16:07

请您先登陆,再发跟帖!