SHARE
TWEET

Untitled

a guest Jun 12th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void merge(int *a, int n1, int *b, int n2, int *merged) {
  2.   int *ap = a, *bp = b;
  3.   while(n1 != 0 && n2 != 0){
  4.     if(*ap < *bp && n2!= 0 && n1 != 0){
  5.         *merged = *ap;
  6.         merged++;
  7.         n1--;
  8.         ap++;
  9.     }else if(*ap > *bp && n2 != 0 && n1 != 0){
  10.         *merged = *bp;
  11.         merged++;
  12.         n2--;
  13.         bp++;
  14.   }else if(*ap == *bp && n2 != 0 && n1 != 0){
  15.         *merged = *ap;
  16.         merged++;
  17.         *merged = *bp;
  18.         merged++;
  19.         ap++;
  20.         bp++;
  21.         n1--;
  22.         n2--;
  23.   }else if(n2 == 0 && n1 != 0){
  24.       *merged = *bp;
  25.       n2--;
  26.       bp++;
  27.       merged++;
  28.   }else{
  29.       *merged = *ap;
  30.       n1--;
  31.       ap++;
  32.       merged++;
  33. }
  34. }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top