Advertisement
xellscream

CompareTwoArrays

Jan 13th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2.  
  3. class CompareTwoArrays
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Enter the size of the arrays: ");
  8.         int size = int.Parse(Console.ReadLine());
  9.  
  10.         int[] first = new int[size];
  11.         for (int i = 0; i < size; i++)
  12.         {
  13.             Console.Write("Enter value for intex [{0}] of the first array: ", i);
  14.             first[i] = int.Parse(Console.ReadLine());
  15.         }
  16.         Console.WriteLine();
  17.  
  18.         int[] second = new int[size];
  19.         for (int j = 0; j < size; j++)
  20.         {
  21.             Console.Write("Enter value for index [{0}] of the second array: ", j);
  22.             second[j] = int.Parse(Console.ReadLine());
  23.         }
  24.  
  25.         for (int index = 0; index < size; index++)
  26.         {
  27.             Console.Write(first[index] + " ");
  28.             if (first[index] > second[index])
  29.             {
  30.                 Console.Write("> ");
  31.             }
  32.             else if (first[index] < second[index])
  33.             {
  34.                 Console.Write("< ");
  35.             }
  36.             else
  37.             {
  38.                 Console.Write("= ");
  39.             }
  40.             Console.WriteLine(second[index]);
  41.         }
  42.  
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement