Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _7EqualArrays
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array1 = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- int[] array2 = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- int sumNumbers = 0;
- int counter = 0;
- for (int i = 0; i < array1.Length; i++)
- {
- counter++;
- if (array1[i] != array2[i])
- {
- Console.WriteLine($"Arrays are not identical. Found difference at {i} index");
- break;
- }
- else
- {
- int currentNumber = array1[i];
- sumNumbers += currentNumber;
- if (array1.Length == counter)
- {
- Console.WriteLine($"Arrays are identical. Sum: {sumNumbers}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment