• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Oct 13th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. n = int(input()) # Размерность матрицы
2. matrix = [ [0 for i in range(n)] for i in range(n)]
3.
4. # считываем значения
5. for i in range(n):
6.     line = input()
7.     if (len(line) == 0):
8.         continue
9.     print("line", line)
10.     for j, el in enumerate(line.split(" ")):
11.         print("el", el)
12.         matrix[i][j] = int(el)
13.
14. def is_transitive(matrix):
15.     for k in range(n):
16.         for i in range(n):
17.             for j in range(n):
18.                 if (k == i or k == j):
19.                     continue
20.                 if (matrix[i][k] == 1 and matrix[k][j] == 1 and  matrix[i][j] == 0):
21.                     return False
22.     return True
23.
24.
25. if (is_transitive(matrix)):
26.     print("Матрица транзитивна")
27. else:
28.     print("Матрица не транзитивна")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?