static int[] Unite2SortedArrays(int[] a, int[] b)
//Объединяет отсортированные массивы a и b в один, результат тоже отсортирован
{
int[] Result = new int[a.Length + b.Length];
int ai = 0, bi = 0;
for (int i = 0; i < Result.Length; i++)
{
if (bi == b.Length || ai < a.Length && a[ai] < b[bi] )
{
Result[i] = a[ai];
ai++;
}
else
{
Result[i] = b[bi];
bi++;
}
}
return Result;
}