javascript 写了个字符串组合的情况

function log() {
var i = 0,
str = '',
args = [].slice.call(arguments); j++;
if (isRepeat(args)) {
k++;
return;
} while(i < args.length) {
str += chars[args[i]];
i++;
}
console.log(str);
} function count(obj) {
var i = 0;
for (var p in obj) {
if (obj.hasOwnProperty(p)) {
i++;
}
}
return i;
}
function isRepeat(arr) {
var i = 0,
obj = {};
while(i < arr.length) {
obj[typeof arr[i] + arr[i]] = 1;
if (count(obj) === i) {
return true;
}
i++;
} return false;
}
function loop(min, max, fn, count) {
var i, args;
i = min;
count++;
args = [].slice.call(arguments, 0); while(i < max) {
var iargs = args.slice(0);
iargs.push(i); fn.apply(window, iargs.slice(4)); if (count < max - min) {
arguments.callee.apply(window, iargs);
} i++;
}
} var chars = ['a', 'b', 'c', 'd', 'e', 'f']; var j = 0, k = 0;
loop(0, chars.length, log, 0);
console.log('共执行', j, '次, 不允许单字符重用有', j - k, '次, 允许单字符重用有', k, '次');
上一篇:zabbix zatree centos7安装zabbix-agent


下一篇:C语言中的补码与反码(-1的十六进制ffffffff)