Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by Andrey ( 12 years ago )
void merge(int *array1, int array1Length, int *array2, int array2Length, int *result)
{
 int i = 0, j = 0, k = 0;

 while (i < array1Length || j < array2Length)
 {
  if (i < array1Length && j < array2Length)
  {
   if (array1[i] <= array2[j])
   {
    result[k] = array1[i];
    i++;
    k++;
   }
   else
   {
    result[k] = array2[j];
    j++;
    k++;
   }
   continue;
  }

  if (i < array1Length)
  {
   result[k] = array1[i];
   i++;
   k++;
   continue;
  }

  if (j < array2Length)
  {
   result[k] = array2[j];
   j++;
   k++;
   continue;
  }
 }
}

 

Revise this Paste

Parent: 74304
Your Name: Code Language: