package ru.job4j.exam;
/**
 * Class FirstExam соединяет 2 отсортированных массива.
 * @author Andrey Sagirov (mailto:andrey.sagirov23@gmail.com)
 * @version $Id$
 * @since 08.09.2017
 */
public class FirstExam {
	/**
	* @param first массив.
	* @param second массив.
	* @return third.
	*/
	public int[] united(int[] first, int[] second) {
		if (first == null) {
		return second;
		}
		if (second == null) {
		return first;
		}
		int[] third = new int[first.length + second.length];
		int firstIndex = 0;
		int secondIndex = 0;
		for (int i = 0; i < third.length - 1; i++) {
			if (first[firstIndex] < second[secondIndex] || secondIndex == second.length) {
				third[i] = first[firstIndex];
				firstIndex++;
			} else if (first[firstIndex] > second[secondIndex] || firstIndex == first.length) {
				third[i] = second[secondIndex];
				secondIndex++;
			} else {
				third[i] = first[firstIndex];
				third[i + 1] = second[secondIndex];
				i = i + 1;
				firstIndex++;
				secondIndex++;
			}
		}
	return third;
	}
}
@@ -557,12 +557,8 @@
 ngth
- - 1
 ; i+
@@ -578,22 +578,47 @@
 irst
-%5BfirstIndex%5D %3C
+Index %3E= first.length) %7B%0A%09%09%09%09third%5Bi%5D =
  sec
@@ -633,20 +633,51 @@
 ndIndex%5D
- %7C%7C 
+;%0A%09%09%09%09secondIndex++;%0A%09%09%09%7D else if (
 secondIn
@@ -680,17 +680,17 @@
 ndIndex 
-=
+%3E
 = second
@@ -784,17 +784,17 @@
 tIndex%5D 
-%3E
+%3C
  second%5B
@@ -809,42 +809,123 @@
 dex%5D
- %7C%7C firstIndex == first.length
+) %7B%0A%09%09%09%09third%5Bi%5D = first%5BfirstIndex%5D;%0A%09%09%09%09firstIndex++;%0A%09%09%09%09%7D else if (first%5BfirstIndex%5D %3E second%5BsecondIndex%5D
 ) %7B%0A
+%09
 %09%09%09%09
@@ -952,32 +952,33 @@
 condIndex%5D;%0A%09%09%09%09
+%09
 secondIndex++;%0A%09
@@ -968,32 +968,34 @@
 %09secondIndex++;%0A
+%09%09
 %09%09%09%7D else %7B%0A%09%09%09%09

task 24312