Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int indexA = 0;
- int indexB = 0;
- int indexC = 0;
- while((indexA < 5) && (indexB < 5))
- {
- running++;
- running++;
- if (hundredArray1[indexA] < hundredArray2[indexB])
- {
- running++;
- hundredArrayOutput[indexC] = hundredArray1[indexA];
- indexA++; //increase the subscript
- }
- else
- {
- running++;
- hundredArrayOutput[indexC] = hundredArray2[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 < 5)
- {
- running++;
- hundredArrayOutput[indexC] = hundredArray1[indexA];
- indexA++;
- indexC++;
- }
- while (indexB < 5)
- {
- running++;
- hundredArrayOutput[indexC] = hundredArray2[indexB];
- indexB++;
- indexC++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement