0804 - Col Egale

From Bitnami MediaWiki
Revision as of 19:34, 3 April 2023 by Andor Giulia (talk | contribs) (Pagină nouă: == Rezolvare == <syntaxhighlight lang="python" line="1"> m, n = map(int, input().split()) matrix = [] for i in range(m): row = list(map(int, input().split())) matrix.append(row) found = False for j in range(n): col = [matrix[i][j] for i in range(m)] if len(set(col)) == 1: print(col[0], end=' ') found = True if not found: print("nu exista") </syntaxhighlight>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Rezolvare

<syntaxhighlight lang="python" line="1"> m, n = map(int, input().split())

matrix = [] for i in range(m):

   row = list(map(int, input().split()))
   matrix.append(row)

found = False for j in range(n):

   col = [matrix[i][j] for i in range(m)]
   if len(set(col)) == 1:
       print(col[0], end=' ')
       found = True

if not found:

   print("nu exista")

</syntaxhighlight>