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