Advertisement
spasnikolov131

Untitled

Nov 10th, 2022
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Demo
  6. {
  7. internal class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int[] arr1 = Console.ReadLine()
  12. .Split()
  13. .Select(int.Parse)
  14. .ToArray();
  15.  
  16. int[] arr2 = Console.ReadLine()
  17. .Split()
  18. .Select(int.Parse)
  19. .ToArray();
  20.  
  21. int sum = 0;
  22. int sum2 = 0;
  23.  
  24. for (int i = 0; i < arr1.Length; i++)
  25. {
  26. sum += arr1[i];
  27. }
  28. for (int i = 0; i < arr2.Length; i++)
  29. {
  30. sum2 += arr2[i];
  31. }
  32. if (sum == sum2)
  33. {
  34. Console.WriteLine($"Arrays are identical. Sum: {sum}");
  35. }
  36. else
  37. {
  38. Console.WriteLine($"Arrays are not identical. Found difference at 2 index");
  39.  
  40. }
  41.  
  42. }
  43. }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement