let num1 = 1;
let num2 = 2;
let num3 = 3;
let num4 = 4;
let array1=NSMutableArray.init(array: [num1,num2,num3,num4]);
let array22 = NSMutableArray.init(array: []);
for index1 in 0..<4 {
let a1 = array1[index1]
for index2 in 0..<4
{
let a2=array1[index2]
if (a1 as! Int)==(a2 as! Int) {
continue;
}
for index3 in 0..<4
{
let a3=array1[index3]
if (a1 as! Int)==(a3 as! Int)||(a2 as! Int)==(a3 as! Int) {
continue;
}else{
let mid = (a1 as! Int)*100+(a2 as! Int)*10+(a3 as! Int)
array22.add(mid);
}
}
}
}
print("不重复",array22.count)
print( array22)
网友评论