Advertisement
dentia

arrays

Jan 18th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Arrays
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[] a = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  10.             int[] b = new int[] { 10, 11, 12 };
  11.  
  12.             int[] c = new int[Math.Max(a.Length, b.Length)];
  13.  
  14.             for (int index = 0; index < c.Length; index++)
  15.             {
  16.                 int aValue = (a.Length > index) ? a[index] : b[index];
  17.                 int bValue = (b.Length > index) ? b[index] : a[index];
  18.  
  19.                 c[index] = Math.Max(aValue, bValue);
  20.             }
  21.  
  22.             //Console.WriteLine(String.Join(", ", c));
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement