Nepenthe Posted May 28, 2019 Report Posted May 28, 2019 Salut! Am nevoie de ajutor cu problema urmatoare (p.s.: mersi anticipat): https://imgur.com/eX6Zvzx Quote
Nepenthe Posted May 28, 2019 Author Report Posted May 28, 2019 @gigiRoman da.. imi citeste 0.. nu stiu de ce. Quote
Guest Posted May 28, 2019 Report Posted May 28, 2019 (edited) Rezolvare: https://ideone.com/qcW6Yp Tu adunai la suma contorul j, nu elementele din numere. Edited May 28, 2019 by Guest Quote
Nepenthe Posted May 28, 2019 Author Report Posted May 28, 2019 public static void math4() { int[] numere = { 84, 93, 72, 34, 91, 16, 8, 83, 93, 42 }; int sum = 0; for (int i = 1; i < numere.Length; i += 2) { for(int j = 0; j % 2 == 0; j++) { sum += j; Console.WriteLine("Suma numerelor pare de pe pozitiile impare este " + sum); } } Console.ReadLine(); } Quote
Guest Posted May 28, 2019 Report Posted May 28, 2019 1 minute ago, aismen said: Rezolvare: https://ideone.com/qcW6Yp Tu adunai la suma contorul j, nu elementele din numere. Just now, Nepenthe said: public static void math4() { int[] numere = { 84, 93, 72, 34, 91, 16, 8, 83, 93, 42 }; int sum = 0; for (int i = 1; i < numere.Length; i += 2) { for(int j = 0; j % 2 == 0; j++) { sum += j; Console.WriteLine("Suma numerelor pare de pe pozitiile impare este " + sum); } } Console.ReadLine(); } Quote