Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. namespace Diagonal_Difference
  2. {
  3. using System;
  4. using System.Linq;
  5.  
  6. public class Program
  7. {
  8. public static void Main(string[] args)
  9. {
  10. int size = int.Parse(Console.ReadLine());
  11.  
  12. int sumLeft = 0;
  13. int sumRight = 0;
  14.  
  15. int[,] matrix = new int[size, size];
  16.  
  17. for (int i = 0; i < matrix.GetLength(0); i++)
  18. {
  19. int[] array = Console.ReadLine()
  20. .Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
  21. .Select(int.Parse)
  22. .ToArray();
  23. for (int j = 0; j < matrix.GetLength(1); j++)
  24. {
  25. matrix[i, j] = array[j];
  26. }
  27. sumLeft += array[i];
  28. sumRight += array[array.Length - i - 1];
  29. }
  30. Console.WriteLine(Math.Abs(sumLeft - sumRight));
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement