Seudónimo Seudónimo
  • 16-12-2020
  • Computers and Technology
contestada

Given a MxN matrix.Print the elements in odd rows from left to right and the elements in even rows from right to left.(Java or C++)

Respuesta :

shazamzeus21 shazamzeus21
  • 16-12-2020

given the array arr[][]:

 bool leftToRight = true;

 for (int i=0; i<M; i++)

   {

       if (leftToRight)

       {

           for (int j=0; j<N; j++)

               printf("%d ", arr[i][j]);

       }

       else

       {

           for (int j=N-1; j>=0; j--)

               printf("%d ",arr[i][j]);

       }

 

       leftToRight = !leftToRight;

   }

Answer Link

Otras preguntas

7-108. answer each of the question below
Need help an plz show me how you know so you can give me the work
The garbage that____near the sidewalk smells awful
The qualification for president under article 2 of the constitution is? (A)being born in the US (B)Being born in Washington DC (C)living for ten years in the US
Simplify the expression. Explain each step (3y) x 9
how do you solve this question?
Which of the following is a key reason to include hyperbole in a literary work? I. to add humor Il. to heighten effect III. to create suspense
________ is/are most likely to understand trade issues in the united states.
Jerry can assemble a computer​ by himself in 45 minutes. working with an assistant, he can assemble a computer in 40 minutes. how long would it take his assista
At the national level, public offices can be filled by election or appointment. Why do you think the constitution does not provide for the presidency to be fill