Question: Write a program that reverses the order of the elements in each row of the matrix. Print out the resulting matrix. import java.io . *

Write a program that reverses the order of the elements in each row of the matrix.
Print out the resulting matrix.
import java.io.* ;
public class ReverseRow
{
static int[][] data ={{3,2,5},
{1,4,4,8,13},
{9,1,0,2},
{0,2,6,3,-1,8},
{-1,-2,-3,4,5,45},
{56},
{0,1,2,3,4,5,6,7}};
private static void printArray()
{
for ( int row=0; row < data.length; row++)
{
for ( int col=0; col < data[row].length-1; col++)
System.out.print( data[row][col]+",");
System.out.println( data[row][data[row].length-1]);
}
}
public static void main ( String[] args )
{
// print out the initial array
printArray();
System.out.println();
// reverse each row
for ( int row=0; row < data.length; row++)
{
int endInx = data[row].length;
for ( int col=0; col <??? ; col++)
{
//--- INSERT CODE HERE ---//
}
}
// print out the reversed array
printArray();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!