Superdiagonals X54207


Statement
 

pdf   zip

html

The superdiagonal of a matrix m is formed by the elements m[i][j] in the matrix for which the column is one position more than the row: j = i+1 (see https://en.wikipedia.org/wiki/Diagonal#Matrices); that is, those elements lying along the diagonal just above the main diagonal. Write a program that computes the sums of the superdiagonals of several matrices.

Input

Input is a sequence of cases. Each case starts with a nonnegative integer n, followed by a square n × n matrix of integers.

Output

The sum of the superdiagonal elements of each matrix, in the same order, each in a line of its own.

Public test cases
  • Input

    3
    0 2 0
    0 0 3
    0 0 0
    4
    1 0 1 1
    2 2 0 2
    3 3 3 0
    4 4 4 4
    1
    -1234
    2
    77 1
    88 99

    Output

    5
    0
    0
    1
    
  • Information
    Author
    José Luis Balcázar
    Language
    English
    Official solutions
    Python
    User solutions
    Python