//Function to merge two pre-sorted arrays
void MergeSort(apvector &arrayA,
apvector &arrayB, apvector &arrayC)
{
int indexA = 0; // initialize
variables for the subscripts
int indexB = 0;
int indexC = 0;
while((indexA < arrayA.length( )) && (indexB < arrayB.length( ))
{
if (arrayA[indexA] < arrayB[indexB])
{
arrayC[indexC] = arrayA[indexA];
indexA++; //increase the
subscript
}
else
{
arrayC[indexC] = arrayB[indexB];
indexB++; //increase the
subscript
}
indexC++; //move to the next
position in the new array
} // Move remaining elements to end of new
array when one merging array is empty
while (indexA < arrayA.length( ))
{
arrayC[indexC] = arrayA[indexA];
indexA++;
indexC++;
}
while (indexB < arrayB.length( ))
{
arrayC[indexC] = arrayB[indexB];
indexB++;
indexC++;
}
return;
}
+ نوشته شده در چهارشنبه بیست و سوم دی ۱۳۸۸ ساعت 17:1 توسط پروژه برنامه نویسی و طراحی وب سایت
|
رشته من نرم افزار است. در حال حاضر بر روي پروژه هاي برنامه نویسی ، طراحی وب سایت ، تحلیل پروژه های نرم افزاری و طراحی پایگاه داده فعالیت می کنم.