Demo entry 6647053

直接选择排序算法

   

Submitted by 52 on Oct 19, 2017 at 02:31
Language: Objective-C++. Code size: 433 Bytes.

void Quickly_SORT(int[] R)
{   
    for (int i = 0; i < len-1; i++)//i为外层循环变量
    {
        int index = i;
        for (int j = i + 1; j < len; j++)//j为内层循环变量
        {
            if (R[j] > R[index])
            {
                index = j;
            }
        }
         if (index != i)//判断index是否发生了变化
        {
            int t = R[i]; R[i] = R[index]; R[index] = t;//将R[i]与R[index]的值交换
        }
    }    
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).