美文网首页
Swift 1,2,3,4 循环

Swift 1,2,3,4 循环

作者: 本泽马 | 来源:发表于2017-11-22 20:06 被阅读0次

    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)

    相关文章

      网友评论

          本文标题:Swift 1,2,3,4 循环

          本文链接:https://www.haomeiwen.com/subject/pybovxtx.html