Swift:执行被中断原因exc_bad_instruction(code = exc_i386_invop subcode = 0x0)

时间:2016-07-28 14:46:15

标签: swift

当我使用函数ShakerSort()时,我收到一个错误:执行被中断的原因是exc_bad_instruction(code = exc_i386_invop subcode = 0x0)。

func ShakerSort(data : [Int]) -> [Int]
{
    var output = [Int]()
    var start=0, end=data.count-1, index : Int

    for index in start...end{output+=[data[index]];}

    while (start<=end)
    {
        for index in end...start{
            if (output[index-1]>output[index]) {var Number = output[index-1]; output[index-1]=output[index]; output[index]=Number;}
            start+=1;
            for index in start...end{
                if (output[index-1]>output[index]) {var Number = output[index-1]; output[index-1]=output[index]; output[index]=Number;}
                end-=1;
            }
        }
    }
    return output
}
let mather = [34,32,12,7,5,353,76,3]
ShakerSort(mather)

0 个答案:

没有答案