<script>
var stack = new Array("a","b","c","d","e","f","g","h","i","j","k","l");
var buff = new Array();
function getComb(stack, buff)
{
if(stack.length + buff.length < 5) return; //字母不夠了,不用再試
while(stack.length > 0) //字母還沒(méi)用完
{
buff.push(stack.shift()); //選取字母
if(buff.length < 5) //還沒(méi)到5個(gè)字母
{
getComb(stack.slice(0), buff.slice(0)); //繼續(xù)選取
}
else if(buff.length == 5)
{
document.write(buff+"<br>"); //夠數(shù)量了,輸出
}
buff.pop(); //丟棄用過(guò)的字母
}
return;
}
getComb(stack, buff);
</script>