[Rezolvare] Trace suma/pozitive (s=35, t=3)
Posted: Tue Sep 22, 2026 7:44 pm
Trace: suma + numarare pozitive
Enuntul complet in imaginea atasata mai jos
Rezolvare (date: 22 -5 10 8 -3 4 0)
Cate valori se citesc? wrote:Bucla for merge i=1..4 → doar PRIMELE 4 valori: 22, -5, 10, 8. Restul (-3 4 0) sunt momeala, nu se citesc!
Code: Select all
i=1: x=22 → s=22, x>0 → t=1
i=2: x=-5 → s=17, x<=0 → cout "-5"
i=3: x=10 → s=27, t=2
i=4: x=8 → s=35, t=3
cout << endl; // rand nou
cout << s << ',' << t → 35,3Code: Select all
-5
35,3Enunt (foto):