C++???????????
???????????? ???????[ 2015/11/3 14:14:37 ] ??????????????????? .NET
???????????????????????????????????ν?????????????????????????????λ???????????????????????????????λ?á????λ???????????????????Ч????????????????????????????????????????????????????Ч???
????____________________________________________________________________________________________________
???????????
??????????е????????????????????δ??????????δ???????????????????????????????????????????м?λ??????м?λ????????С?????????С?????????λ??????????λ??????????м?????????????????λ?????????????????????λ????????????????????????????????????????м??ɡ?
????C++????????C++???
#include<iostream>
usingnamespacestd;
voidHalfSort(int*array??intLength)
{//??????????м???????????????????λ??
intlow??high??middle??temp??index??i??j;
for(i=1;i<Length;i++)//????????????????δ??±??1???????
{//???????array[0]?????????????????У???????????
low=0;
high=i-1;
temp=array[i];
index=i;
if(array[0]<temp&&array[i-1]>temp)//???β???????????Χ????????
{
while(low<=high)//????????????λ??
{
middle=(low+high)/2;
if(array[middle]>temp)
{
high=middle-1;
}
else
low=middle+1;
}
//?????λ??index
index=low;
}
if(array[0]>=temp)//?????????????С???嵽?????λ??
{index=0;}
if(array[i-1]<=temp)//??????????????????嵽?????λ??
{index=i;}
//?????λ?????????
for(j=i-1;j>=index;j--)
{array[j+1]=array[j];}
array[index]=temp;//????
}
//???
for(i=0;i<Length;i++)
{
cout<<array[i]
<<"";
}
cout<<endl;
}
voidmain()
{
intarray[]={63??4??24??1??3??15};
intLength=sizeof(array)/sizeof(array[0]);//??????
HalfSort(array??Length);
}_____________________________________________________________________________________________________________________________________________________________________
????????????????????????????????????в????if(array[0]<temp&&array[i-1]>temp)??if(array[0]>=temp????if(array[i-1]<=temp)???????ж??????????????????????????????Щ?ж???????????????????????????????????е?????????????Щ?????????????????????????е??????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11