nikiman8888

EqualArrays

Oct 7th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading;
  6.  
  7. namespace _07._EqualArrays
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] firstArray = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14.  
  15.             int[] secondArray = Console.ReadLine().Split().Select(int.Parse).ToArray();
  16.  
  17.             int sum = 0;
  18.  
  19.             for (int i = 0; i < firstArray.Length; i++)
  20.             {
  21.                 if (firstArray[i] != secondArray[i])
  22.                 {
  23.                     Console.WriteLine($"Arrays are not identical. Found difference at {i} index");
  24.                     return;
  25.                 }
  26.             }
  27.             Console.WriteLine("Arrays are identical. Sum: {0}",firstArray.Sum());
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment