Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. namespace Matrix_HW
  2. {
  3. using System;
  4. using System.Linq;
  5.  
  6. public class Program
  7. {
  8. public static void Main()
  9. {
  10. int size = int.Parse(Console.ReadLine());
  11. int[,] matrix = new int[size, size];
  12. int sumL = 0;
  13. int sumR = 0;
  14.  
  15. for (int row = 0; row < size; row++)
  16. {
  17. var currRow = Console.ReadLine().Split().Select(int.Parse).ToArray();
  18. if (currRow.Length == size)
  19. {
  20. for (int col = 0; col < size; col++)
  21. {
  22. matrix[row, col] = currRow[col];
  23. }
  24. }
  25. }
  26.  
  27. for (int row = 0; row < matrix.GetLength(0); row++)
  28. {
  29. sumL += matrix[row, row];
  30. }
  31. for (int row = 0; row < matrix.GetLength(0); row++)
  32. {
  33. sumR += matrix[row, matrix.GetLength(0) - 1 - row];
  34. }
  35.  
  36. Console.WriteLine(Math.Abs(sumL - sumR));
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement