Jump to content

Recommended Posts

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();
        }

Share this post


Link to post
Share on other sites
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();
        }

 

  • Like 1
  • Downvote 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...