3998 - Sum Max 9

From Bitnami MediaWiki
Revision as of 18:34, 29 March 2023 by Andor Giulia (talk | contribs) (Pagină nouă: == Rezolvare == <syntaxhighlight lang="python" line="1"> n = int(input("Introduceti numarul de perechi: ")) perechi = [] for i in range(n): a, b = map(int, input(f"Introduceti perechea {i+1}: ").split()) perechi.append((a, b)) suma_maxima = 0 for a, b in perechi: suma_maxima += max(a, b) print(f"Suma maxima este: {suma_maxima}") </syntaxhighlight>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Rezolvare

<syntaxhighlight lang="python" line="1"> n = int(input("Introduceti numarul de perechi: ")) perechi = [] for i in range(n):

   a, b = map(int, input(f"Introduceti perechea {i+1}: ").split())
   perechi.append((a, b))

suma_maxima = 0 for a, b in perechi:

   suma_maxima += max(a, b)

print(f"Suma maxima este: {suma_maxima}") </syntaxhighlight>