Advertisement
coasterka

AreTwoArraysEqual

Mar 11th, 2014
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace AreTwoArraysEqual
  4. {
  5.     class AreTwoArraysEqual
  6.     {
  7.         static void Main()
  8.         {
  9.             Console.WriteLine("Input elements of first array.");
  10.             string inputArrayOne = Console.ReadLine();
  11.             Console.WriteLine("Input elements of second array.");
  12.             string inputArrayTwo = Console.ReadLine();
  13.             string[] inputOne = inputArrayOne.Split(' ');
  14.             string[] inputTwo = inputArrayTwo.Split(' ');
  15.             int[] arr1 = new int[inputOne.Length];
  16.             for (int i = 0; i < inputOne.Length; i++)
  17.             {
  18.                 arr1[i] = int.Parse(inputOne[i]);
  19.             }
  20.             int[] arr2 = new int[inputTwo.Length];
  21.             for (int i = 0; i < inputTwo.Length; i++)
  22.             {
  23.                 arr2[i] = int.Parse(inputTwo[i]);
  24.             }
  25.             int counterOfEqualElements = 0;
  26.             if (arr1.Length != arr2.Length)
  27.             {
  28.                 Console.WriteLine("False");
  29.             }
  30.             else
  31.             {
  32.                 for (int i = 0; i < arr1.Length; i++)
  33.                 {
  34.                     if (arr1[i] == arr2[i])
  35.                     {
  36.                         counterOfEqualElements++;
  37.                     }
  38.                 }
  39.                 if (counterOfEqualElements == arr1.Length)
  40.                 {
  41.                     Console.WriteLine("True");
  42.                 }
  43.                 else
  44.                 {
  45.                     Console.WriteLine("False");
  46.                 }
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement