真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

單鏈表的折半查找,冒泡排序,選擇排序-創(chuàng)新互聯(lián)

//選擇排序

創(chuàng)新互聯(lián)10多年成都定制網(wǎng)頁設(shè)計(jì)服務(wù);為您提供網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)頁設(shè)計(jì)及高端網(wǎng)站定制服務(wù),成都定制網(wǎng)頁設(shè)計(jì)及推廣,對(duì)不銹鋼雕塑等多個(gè)行業(yè)擁有多年的網(wǎng)站推廣經(jīng)驗(yàn)的網(wǎng)站建設(shè)公司。

void SelectSort(SeqList* pSeqList)

{

                int i = 0, j = 0;

                int iMaxPos = 0;

                int iMinPos = 0;

                DataType temp;

for (; i < pSeqList->Size/2; ++i)

  {

     iMaxPos = i;

     iMinPos = i;

    for(j = 1; j < pSeqList->Size - i; j++)

      {

      if (pSeqList->arry[iMaxPos] < pSeqList->arry[j])

           {

                 iMaxPos = j;

           }

      if (pSeqList->arry[iMinPos] > pSeqList->arry[j])

           {

               iMinPos = j;

            }

      }

    if (iMaxPos != i)

     {

          temp = pSeqList->arry[iMaxPos];

        pSeqList->arry[iMaxPos] = pSeqList->arry[pSeqList->Size - i - 1];

        pSeqList->arry[pSeqList->Size - i - 1] = temp;

      }

     if (iMinPos != i)

     {

         temp = pSeqList->arry[iMinPos];

          pSeqList->arry[iMinPos] = pSeqList->arry[i];

          pSeqList->arry[i] = temp;

      }

  }

}

//冒泡排序

void BorbbleSort(SeqList* pSeqList)

{

                int iCount = 0;

                int iBegin = 0;

                int iFlag = 0;

                if (NULL == pSeqList)

                {

                                return;

                }

    for (; iCount Size - 1; iCount++)

    {

        iFlag = 1;

        for (iBegin = 0; iBegin < pSeqList->Size - iCount - 1; ++iBegin)

        {

          if (pSeqList->arry[iBegin] > pSeqList->arry[iBegin+1])

           {

                DataType temp = pSeqList->arry[iBegin];

                pSeqList->arry[iBegin] = pSeqList->arry[iBegin+1];

                pSeqList->arry[iBegin+1] = temp;

                 iFlag = 0;

            }

          }

          if (iFlag)

          {

             return;

          }

     }

}

// 折半查找

int BinarySearch(SeqList* pSeqList, DataType data)

{

                int iLeft = 0;

                int iRight = pSeqList->Size;// [)

                //int iMid = (iLeft + iRight)/2;

                int iMid = 0;

                DataType temp;

                if (NULL == pSeqList)

                {

                                return;

                }

                // [0, 4]

                while(iLeft < iRight)

                {

                                iMid = iLeft + (iRight - iLeft)/2;

                                temp = pSeqList->arry[iMid];

                                if (temp < data)

                                {

                                                iLeft = iMid;

                                }

                                else if (temp > data)

                                {

                                                iRight = iMid - 1;

                                }

                                else

                                {

                                                return iMid;

                                }

                }

                return -1;

}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


文章標(biāo)題:單鏈表的折半查找,冒泡排序,選擇排序-創(chuàng)新互聯(lián)
本文URL:http://weahome.cn/article/epooc.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部