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 ChexReverseRowastu
static int data ragged array, "data"
;
private static void printArray
PLN;
for int row; row data.length; row process by rows
for int col; col datarowlength; col process each column of a row
P datarowcol; scope is one line, not a block
PLN datarowdatarowlength;
public static void main String args
printArray; print out the initial array
for int row; row data.length; row process all rows
int endIdx datarowlength; determine ending column number
for int col; col endIdx ; col# use half the row; evenodd #
insert code here
# standard swap #
# put end col into start col #
# be careful with 'off by one' #
# half cols because of swapping #
printArray; print out the rowreversed array
public static void PObject xSystemout.printx; Shorthand System.out.print
public static void PLNObject xSystemout.printlnx; Shorthand System.out.println
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
