<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=0767_-_Suma_Pare2</id>
	<title>0767 - Suma Pare2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=0767_-_Suma_Pare2"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0767_-_Suma_Pare2&amp;action=history"/>
	<updated>2026-05-01T12:50:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=0767_-_Suma_Pare2&amp;diff=2899&amp;oldid=prev</id>
		<title>Andor Giulia at 17:19, 4 April 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0767_-_Suma_Pare2&amp;diff=2899&amp;oldid=prev"/>
		<updated>2023-04-04T17:19:54Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;//wiki.universitas.ro/index.php?title=0767_-_Suma_Pare2&amp;amp;diff=2899&amp;amp;oldid=538&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Andor Giulia</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=0767_-_Suma_Pare2&amp;diff=538&amp;oldid=prev</id>
		<title>Bogdan.Pop: Pagină nouă: Sursa: [https://www.pbinfo.ro/probleme/767/sumapare2 0767 - Suma Pare 2] ---- == Cerinţa == Se dă o &#039;&#039;&#039;matrice&#039;&#039;&#039; cu &#039;&#039;&#039;lin&#039;&#039;&#039; linii şi &#039;&#039;&#039;col&#039;&#039;&#039; coloane şi elemente numere naturale. Determinați suma valorilor pare din &#039;&#039;&#039;matrice&#039;&#039;&#039;. == Date de intrare == Programul citește de la tastatură numerele &#039;&#039;&#039;lin&#039;&#039;&#039; şi &#039;&#039;&#039;col&#039;&#039;&#039;, iar apoi &#039;&#039;lin * col&#039;&#039; numere naturale, separate prin spaţii, reprezentând elementele matricei, linie cu linie. == Date de ieșire ==  Pe ecran se...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0767_-_Suma_Pare2&amp;diff=538&amp;oldid=prev"/>
		<updated>2023-02-24T16:06:20Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: Sursa: [https://www.pbinfo.ro/probleme/767/sumapare2 0767 - Suma Pare 2] ---- == Cerinţa == Se dă o &amp;#039;&amp;#039;&amp;#039;matrice&amp;#039;&amp;#039;&amp;#039; cu &amp;#039;&amp;#039;&amp;#039;lin&amp;#039;&amp;#039;&amp;#039; linii şi &amp;#039;&amp;#039;&amp;#039;col&amp;#039;&amp;#039;&amp;#039; coloane şi elemente numere naturale. Determinați suma valorilor pare din &amp;#039;&amp;#039;&amp;#039;matrice&amp;#039;&amp;#039;&amp;#039;. == Date de intrare == Programul citește de la tastatură numerele &amp;#039;&amp;#039;&amp;#039;lin&amp;#039;&amp;#039;&amp;#039; şi &amp;#039;&amp;#039;&amp;#039;col&amp;#039;&amp;#039;&amp;#039;, iar apoi &amp;#039;&amp;#039;lin * col&amp;#039;&amp;#039; numere naturale, separate prin spaţii, reprezentând elementele matricei, linie cu linie. == Date de ieșire ==  Pe ecran se...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sursa: [https://www.pbinfo.ro/probleme/767/sumapare2 0767 - Suma Pare 2]&lt;br /&gt;
----&lt;br /&gt;
== Cerinţa ==&lt;br /&gt;
Se dă o &amp;#039;&amp;#039;&amp;#039;matrice&amp;#039;&amp;#039;&amp;#039; cu &amp;#039;&amp;#039;&amp;#039;lin&amp;#039;&amp;#039;&amp;#039; linii şi &amp;#039;&amp;#039;&amp;#039;col&amp;#039;&amp;#039;&amp;#039; coloane şi elemente numere naturale. Determinați suma valorilor pare din &amp;#039;&amp;#039;&amp;#039;matrice&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
== Date de intrare ==&lt;br /&gt;
Programul citește de la tastatură numerele &amp;#039;&amp;#039;&amp;#039;lin&amp;#039;&amp;#039;&amp;#039; şi &amp;#039;&amp;#039;&amp;#039;col&amp;#039;&amp;#039;&amp;#039;, iar apoi &amp;#039;&amp;#039;lin * col&amp;#039;&amp;#039; numere naturale, separate prin spaţii, reprezentând elementele matricei, linie cu linie.&lt;br /&gt;
== Date de ieșire == &lt;br /&gt;
Pe ecran se va afișa mesajul: &amp;quot;Datele de intrare corespund restricțiilor impuse.&amp;quot;, urmat, pe rândul următor, de suma căutată. În cazul în care datele introduse de la tastatură nu îndeplinesc cerințele enunțate, programul va afișa &amp;quot;Datele de intrare nu corespund restricțiilor impuse.&amp;quot;.&lt;br /&gt;
== Restricţii şi precizări ==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;lin&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;col&amp;#039;&amp;#039;&amp;#039; &amp;amp;isin; &amp;amp;#8469;&lt;br /&gt;
* 1 &amp;amp;les; &amp;#039;&amp;#039;&amp;#039;lin&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;col&amp;#039;&amp;#039;&amp;#039; &amp;amp;les; 100&lt;br /&gt;
* &amp;#039;&amp;#039;element matrice&amp;#039;&amp;#039; &amp;amp;isin; &amp;amp;#8469;&lt;br /&gt;
* 0 &amp;amp;les; &amp;#039;&amp;#039;element matrice&amp;#039;&amp;#039; &amp;amp;lt; 10000&lt;br /&gt;
== Exemplu ==&lt;br /&gt;
; Intrare&lt;br /&gt;
: 4 6&lt;br /&gt;
: 4 20 15 23 18 9 &lt;br /&gt;
: 1 8 23 22 14 18&lt;br /&gt;
: 17 15 13 18 12 15 &lt;br /&gt;
: 3 18 8 20 12 5 &lt;br /&gt;
; Ieșire&lt;br /&gt;
: Datele de intrare corespund restricțiilor impuse.&lt;br /&gt;
: 192&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Intrare&lt;br /&gt;
: 3 5&lt;br /&gt;
: 4 20 15 23 18 9 &lt;br /&gt;
: 63.5 8 23 22 14 18&lt;br /&gt;
: 17 15 13 18 12 15 &lt;br /&gt;
: 3 18 8 20 12 5 &lt;br /&gt;
; Ieșire&lt;br /&gt;
: Datele de intrare nu corespund restricțiilor impuse.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Intrare&lt;br /&gt;
: 2 -25&lt;br /&gt;
; Ieșire&lt;br /&gt;
: Datele de intrare nu corespund restricțiilor impuse.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Rezolvare == &lt;br /&gt;
=== Rezolvare ver. 1 ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
# 0767 - Suma Pare 2&lt;br /&gt;
&lt;br /&gt;
def validare_dimensiune_matrice(lin: str, col: str) -&amp;gt; bool:&lt;br /&gt;
    try:&lt;br /&gt;
        int(lin), int(col)&lt;br /&gt;
        if 1 &amp;lt;= int(lin) &amp;lt;= 100 and 1 &amp;lt;= int(col) &amp;lt;= 100:&lt;br /&gt;
            return True&lt;br /&gt;
        else:&lt;br /&gt;
            raise ValueError&lt;br /&gt;
    except ValueError:&lt;br /&gt;
        return False&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
def validare_elemente_matrice(matrice: list, col: int) -&amp;gt; bool:&lt;br /&gt;
    return all(int(matrice[lin][col]) and 0 &amp;lt;= int(matrice[lin][col]) &amp;lt;= 10_000 for lin in range(len(matrice) - 1) for col in range(len(matrice[0]) -1)) and all(len(linie) == col for linie in matrice)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def suma_pare2(matrice: list) -&amp;gt; int:&lt;br /&gt;
    raspuns: int = 0&lt;br /&gt;
    &lt;br /&gt;
    for linie in matrice:&lt;br /&gt;
        for element in linie:&lt;br /&gt;
            if element % 2 == 0:&lt;br /&gt;
                raspuns += element&lt;br /&gt;
                &lt;br /&gt;
    return raspuns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    linia1 = input()&lt;br /&gt;
    linia1 = linia1.split(&amp;quot; &amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    lin: str = linia1[0]&lt;br /&gt;
    col: str = linia1[1]&lt;br /&gt;
    &lt;br /&gt;
    if validare_dimensiune_matrice(lin, col):&lt;br /&gt;
        lin, col = int(lin), int(col)&lt;br /&gt;
        &lt;br /&gt;
        matrice = []&lt;br /&gt;
        &lt;br /&gt;
        for indice_lin in range(lin):&lt;br /&gt;
            linie = input()&lt;br /&gt;
            linie = linie.split(&amp;quot; &amp;quot;)&lt;br /&gt;
            matrice.append(linie)&lt;br /&gt;
            &lt;br /&gt;
        if validare_elemente_matrice(matrice, col):&lt;br /&gt;
            matrice = list(map(lambda lin: list(map(int, lin)), matrice))&lt;br /&gt;
            &lt;br /&gt;
            print(&amp;quot;Datele de intrare corespund restricțiilor impuse.&amp;quot;)&lt;br /&gt;
            print(suma_pare2(matrice))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Datele de intrare nu corespund restricțiilor impuse.&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Datele de intrare nu corespund restricțiilor impuse.&amp;quot;)&lt;br /&gt;
        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bogdan.Pop</name></author>
	</entry>
</feed>