Advertisement
mbratanov

05. Primary Diagonal

Sep 18th, 2024
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. # Read input
  2. n = int(input())
  3. matrix = []
  4. diagonal_sum = 0
  5.  
  6. # Logic
  7. for index in range(n):
  8.     row_data = [int(num) for num in input().split()]
  9.     matrix.append(row_data)
  10.     diagonal_sum += matrix[index][index]
  11.  
  12. # Print output
  13. print(diagonal_sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement