Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OnlineExercise15._4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arrayNum1 = new int[] { 1, 3, 5, 7 };
- int[] arrayNum2 = new int[] { 2, 4, 6, 8 };
- int[] arrayNumber3 = new int[arrayNum1.Length + arrayNum2.Length];
- int i = 0;
- int j = 0;
- int k = 0;
- while(k < arrayNumber3.Length)
- {
- if(i >= arrayNum1.Length )
- {
- arrayNumber3[k] = arrayNum2[j];
- j++;
- }
- else if(j >= arrayNum2.Length)
- {
- arrayNumber3[k] = arrayNum1[i];
- i++;
- }
- else if(arrayNum1[i] < arrayNum2[j])
- {
- arrayNumber3[k] = arrayNum1[i];
- i++;
- }
- else
- {
- arrayNumber3[k] = arrayNum2[j];
- j++;
- }
- k++;
- }
- for(int m = 0; m < arrayNumber3.Length; m++)
- {
- Console.Write(arrayNumber3[m] + " ");
- }
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment