0316 - Min Cols 2: Difference between revisions
Andor Giulia (talk | contribs) Pagină nouă: == Rezolvare == # citirea datelor de intrare m, n = map(int, input().split()) a = [] for i in range(m): row = list(map(int, input().split())) a.append(row) # determinarea valorii minime din matrice min_val = 10000 for i in range(m): for j in range(n): if a[i][j] < min_val: min_val = a[i][j] # înlocuirea elementelor de pe coloanele care conțin valoarea minimă cu valoarea minimă for j in range(n): col_min = 10000 for i in range(m):... |
Andor Giulia (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
== Rezolvare == | == Rezolvare == | ||
<syntaxhighlight lang="python" line> | |||
m, n = map(int, input().split()) | m, n = map(int, input().split()) | ||
a = [] | a = [] | ||
Line 29: | Line 29: | ||
print(a[i][j], end=' ') | print(a[i][j], end=' ') | ||
print() | print() | ||
</syntaxhighlight> |
Revision as of 17:58, 4 April 2023
Rezolvare
<syntaxhighlight lang="python" line> m, n = map(int, input().split()) a = [] for i in range(m):
row = list(map(int, input().split())) a.append(row)
- determinarea valorii minime din matrice
min_val = 10000 for i in range(m):
for j in range(n): if a[i][j] < min_val: min_val = a[i][j]
- înlocuirea elementelor de pe coloanele care conțin valoarea minimă cu valoarea minimă
for j in range(n):
col_min = 10000 for i in range(m): if a[i][j] < col_min: col_min = a[i][j] if col_min == min_val: for i in range(m): a[i][j] = min_val
- afișarea matricei modificate
for i in range(m):
for j in range(n): print(a[i][j], end=' ') print()
</syntaxhighlight>