Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

5. [6 Pts] Prove by cases that if p3 or p7 then (p+2)225

Answered: 1 week ago