Created
August 23, 2012 05:17
-
-
Save tangqiaoboy/3432850 to your computer and use it in GitHub Desktop.
编程计算,由1、2、3、4、5、6六个数码中的五个不同数码组成五位数,把所有组成的五位数按由小到大排序输出。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flag = []; | |
var ans = []; | |
function solve(idx) { | |
if (idx == 5) { | |
console.log(ans.join('')); | |
return; | |
} | |
for (var i = 1; i <= 6; ++i) { | |
if (!flag[i]) { | |
flag[i] = true; | |
ans[idx] = i; | |
solve(idx + 1); | |
flag[i] = false; | |
} | |
} | |
} | |
solve(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment