The basic idea is the same as the previous one:
1: Apply for a K size auxiliary array.
2: Assigning a value to an auxiliary array and sorting from small to large
3: In turn, use the following number and the maximum number of the secondary array to compare, if less than the maximum number of auxiliary arrays replaced, greater than the next comparison
The efficiency of the code is not high, who has a good way to please guide:
#define Min_kij 5
void Binsert_kij (int *array)//To insert sort of auxiliary array
{
int mid,low=0,high=min_kij-2;//Last and former ( K-1) Number comparison
while (Low<=high) //Because it is a sequential array, so direct binary lookup
{
mid= (Low+high)/2;
if (Array[min_kij-1]>array[mid])
{
low=mid+1;
}
else
{
high=mid-1;
}
}
int temp=array[min_kij-1];
for (int i=min_kij-2;i>=high+1;i--)
{
array[i+1]=array[i];
}
array[high+1]=temp;
}
void Min_kijt (int *array1,int *array2)
{
int temp;
int Assint[min_kij];
for (i=1;i<min_kij;i++)//From the second start of the first array and the elements of the second array
{for
(int j=0;j<min_kij;j++)
{
Temp =ARRAY1[I]+ARRAY2[J];
if (temp<assint[min_kij-1])//If the maximum value is less than the secondary array, replace
{
assint[min_kij-1]=temp;
Binsert_kij (Assint); Reorder Secondary Arrays}} for
(i=0;i<min_kij;i++)
{
printf ("%d", Assint[i]);
}