Created
November 24, 2018 18:59
-
-
Save fcschmidt/95fae557705bfe86f60f8718f2375f15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
def diagonal_principal(m): | |
ac = 0 | |
m1 = [] | |
while ac <= len(m) - 1: | |
vet = m[ac] | |
m1.append(vet[ac]) | |
ac += 1 | |
return sum(m1) | |
def diagonal_secundaria(m): | |
dec = len(m) - 1 | |
aux = 0 | |
m2 = [] | |
while dec >= 0: | |
vet = m[aux] | |
m2.append(vet[dec]) | |
dec -= 1 | |
aux += 1 | |
return sum(m2) | |
if __name__ == '__main__': | |
d = int(input()) | |
m = [] | |
for r in range(0, d): | |
matrix = list(map(int, input().split())) | |
m.append(matrix) | |
d_prin = diagonal_principal(m) | |
d_sec = diagonal_secundaria(m) | |
print(d_prin - d_sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment