Advertisement
Guest User

Untitled

a guest
May 5th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. int indexA = 0;
  2.         int indexB = 0;
  3.         int indexC = 0;
  4.  
  5.         while((indexA < 5) && (indexB < 5))
  6.         {
  7.             running++;
  8.             running++;
  9.             if (hundredArray1[indexA] < hundredArray2[indexB])
  10.             {
  11.                 running++;
  12.                 hundredArrayOutput[indexC] = hundredArray1[indexA];
  13.                 indexA++;    //increase the subscript
  14.             }
  15.             else
  16.             {
  17.                 running++;
  18.                 hundredArrayOutput[indexC] = hundredArray2[indexB];
  19.                 indexB++;      //increase the subscript
  20.             }
  21.             indexC++;      //move to the next position in the new array
  22.         }
  23.         // Move remaining elements to end of new array when one merging array is empty
  24.         while (indexA < 5)
  25.         {
  26.             running++;
  27.             hundredArrayOutput[indexC] = hundredArray1[indexA];
  28.             indexA++;
  29.             indexC++;
  30.         }
  31.         while (indexB < 5)
  32.         {
  33.             running++;
  34.             hundredArrayOutput[indexC] = hundredArray2[indexB];
  35.             indexB++;
  36.             indexC++;
  37.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement