Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Comparisson2Arrays
- {
- static void Main()
- {
- Console.Write("Enter the array length: ");
- int length = int.Parse(Console.ReadLine());
- int[] array1 = new int[length];
- int[] array2 = new int[length];
- for (int i = 0; i < length; i++)
- {
- Console.Write("Enter the Array1 Element[{0}] value: ",i+1);
- array1[i] = int.Parse(Console.ReadLine());
- Console.Write("Enter the Array2 Element[{0}] value: ", i+1);
- array2[i] = int.Parse(Console.ReadLine());
- Console.WriteLine();
- }
- for (int i = 0; i < length; i++)
- {
- int compare = array1[i].CompareTo(array2[i]);
- string result = "";
- switch (compare)
- {
- case 1: result = "The element of the first array is bigger"; break;
- case 0: result = "The elements of the two arrays are equal"; break;
- case -1: result = "The element of the second array is bigger"; break;
- }
- Console.WriteLine("Element[{0}]: {1}", i+1, result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement