C\C++冒泡法

bool GetMinK(unsigned int uiInputNum, int * pInputArray)
{
    bool ret = true;
    for(int i=0;i<uiInputNum;i++)
    {
        for(int j=0;j<uiInputNum-1-i;j++)
        {
            int tmp;
            if(pInputArray[j] > pInputArray[j+1])
            {
                tmp = pInputArray[j];
                pInputArray[j] = pInputArray[j+1];
                pInputArray[j+1] = tmp;
            }
        } 
        
    }return ret;
}

 

posted @ 2020-07-28 09:30  朱小勇  阅读(246)  评论(0编辑  收藏  举报