Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace multiArrays
- {
- class Program
- {
- static void Main(string[] args)
- {
- var size = int.Parse(Console.ReadLine());
- var matrix = new int[size, size];
- int primaryDiagonalSum = 0;
- for (int row = 0; row < size; row++)
- {
- var numbers = Console.ReadLine()
- .Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- for (int col = 0; col < size; col++)
- {
- matrix[row, col] = numbers[col];
- if (row == col)
- {
- primaryDiagonalSum += matrix[row, col];
- }
- }
- }
- Console.WriteLine(primaryDiagonalSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement