Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- public class Program
- {
- public static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- long[,] matrix = new long[n,n];
- long primaryDiagonal = 0;
- long secondaryDiagonal = 0;
- for (int row = 0; row < n; row++)
- {
- int[] rowInts = Console.ReadLine().Split().Select(int.Parse).ToArray();
- for (int col = 0; col < n; col++)
- {
- matrix[row, col] = rowInts[col];
- if (row == col)
- {
- primaryDiagonal += rowInts[col];
- }
- if (col == ((n - 1) - row))
- {
- secondaryDiagonal += rowInts[col];
- }
- }
- }
- Console.WriteLine(Math.Abs(primaryDiagonal - secondaryDiagonal));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement