87,963
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
aa=["北京","天津","上海"]
bb=["一汽","三菱"]
cc=["挖掘机","收割机","推土机"]
dd=["哪家强","哪家好"]
Array.prototype.groups = function(x){
if(this.length){
var temp = [];
for(var i = 0;i < this.length;i ++){
for(var n = 0;n < x.length;n ++){
temp.push(this[i] + x[n]);
}
}
return temp.slice(0);
}else{
return x;
}
}
var str = aa.groups(bb);
str = str.groups(cc);
str = str.groups(dd);
console.log(str.join("\n"));
aa=["北京","天津","上海"]
bb=["一汽","三菱"]
cc=["挖掘机","收割机","推土机"]
dd=["哪家强","哪家好"]
Array.prototype.groups = function(x){
if(this.length){
var temp = [];
for(var i = 0;i < this.length;i ++){
for(var n = 0;n < x.length;n ++){
temp.push(this[i] + x[n]);
}
}
return temp.slice(0);
}else{
return x;
}
}
var str = aa.groups(bb);
str = str.groups(cc);
str = str.groups(dd);
console.log(str.join("\n"));
var arr = [
["北京","天津","上海"],
["一汽","三菱"],
["挖掘机","收割机","推土机"],
["哪家强","哪家好"]
];
function loop(i)
{
if (i>=arr.length)
return [""];
var narr = [];
var larr = loop(i+1);
for(var a=0; a<arr[i].length; a++)
for(var b=0; b<larr.length; b++)
narr.push(arr[i][a]+larr[b])
return narr;
}
document.write(loop(0).join("<br />"));
for()
{
for()
{
for()
{
for()
{
}
}
}
}