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

what is the x-intercept and the y-intercept of the graph of 2x+6y=18
Read the following excerpt from Levitt and Dubner’s Freakonomics. The bagel data also reflect how much personal mood seems to affect honesty. Weather, for inst
Use compatible numbers to estimate the quotient 546÷6
Which numbers are roots of the polynomial function shown? Check all that apply. –4 –2 0 2 4 6
What is 2×4+6×2+12+2+3
Need help for the 2 questions on the bottom
What kind of change is it when a liquid turns into a gas by boiling????????????????????
What is 45.385 rounded to the nearest hundredth
what is a device that converts thermal energy into mechanical energy
Which was not a broad trend from 1450 to 1750 in economic development?Which was not a broad trend from 1450 to 1750 in economic development? A. Sources of wealt