Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace HomeWork
- {
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- var matrix = new double[n][];
- for (int rowsIndex = 0; rowsIndex < n; rowsIndex++)
- {
- var nums = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
- matrix[rowsIndex] = nums;
- }
- double diagonalSum1 = 0;
- for (int i = 0; i < n; i++)
- diagonalSum1 += matrix[i][i];
- double diagonalSum2 = 0;
- int start = n - 1;
- for (int i = 0; i < n; i++)
- {
- diagonalSum2 += matrix[i][start];
- start--;
- }
- Console.WriteLine(Math.Abs(diagonalSum1 - diagonalSum2));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement