Advertisement
Guest User

Untitled

a guest
Dec 20th, 2018
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace probenApp
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] array1 = Console.ReadLine()
  11.                 .Split(" ")
  12.                 .Select(int.Parse)
  13.                 .ToArray();
  14.  
  15.             int[] array2 = Console.ReadLine()
  16.                 .Split(" ")
  17.                 .Select(int.Parse)
  18.                 .ToArray();
  19.  
  20.             for (int i = 0; i < array1.Length; i++)
  21.             {
  22.                 if (array1[i] != array2[i])
  23.                 {
  24.                     Console.WriteLine($"Arrays are not identical. Found difference at {i} index");
  25.                     break;
  26.                 }
  27.                 else if (array1[i] == array2[i])
  28.                 {
  29.                     int sum = array1.Sum();
  30.                     Console.WriteLine($"Arrays are identical. Sum: {sum}");
  31.                     break;
  32.                 }
  33.             }
  34.         }
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement