求叠数的c语言代码
答案:1 悬赏:40 手机版
解决时间 2021-04-01 14:10
- 提问者网友:几叶到寒
- 2021-04-01 00:22
求叠数的c语言代码
最佳答案
- 五星知识达人网友:第幾種人
- 2021-04-01 00:53
void Bin_Insert_Sort( int a[], int length )
{
for ( int i=1; i
// If the adjacent has been order;
if ( a[i] > a[i-1] )
{
continue;
}
int low = 0;
int high = i-1;
int temp = a[i];
// Search the position for insert;
while( low <= high )
{
int mid = (low+high)/2;
if ( temp < a[mid] )
{
high = mid-1;
}
else if ( temp > a[mid] )
{
low = mid+1;
}
else
{
break;
}
} // End of "while(low<=high)";
// The position after move back;
int j = i;
while ( j >= low )
{
a[j--] = a[j-1];
}
a[low] = temp; // Insert the value;
} // End of "for(int i=1;i
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯