Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void merge(int[] array, int left, int mid, int right)
- {
- int i;
- int left_counter = 0;
- int right_counter = mid + 1;
- int[] sorted = new int[10];
- for (i = 0; i <= right; i++)
- {
- if ((left_counter <= mid) && (right_counter <= right))
- {
- if (array[left_counter] < array[right_counter])
- {
- sorted[i] = array[left_counter];
- left_counter++;
- }
- else {
- sorted[i] = array[right_counter];
- right_counter++;
- }
- }
- if (left_counter > mid)
- {
- sorted[i] = array[right_counter];
- right_counter++;
- }
- if (right_counter > right)
- {
- sorted[i] = array[left_counter];
- left_counter++;
- }
- }
- for (i = 0; i <= right; i++)
- {
- array[i] = sorted[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement