int[][] arr = new int[m][n]; System.out.println("Enter the values of the matrix row wise.");
for (int i = 0; i < m; i++) { for (int j = 0; j &XX; n; X++) { XXX[i][j] = Integer.XXXXXXXX(sc.XXXXXXXX()); } } sc.close(); XXXXXX.out.XXXXXXX(); XXXXXX.out.XXXXXXX("Your entered matrix XX : ");
for (XXX i = X; i &XX; m; i++) { XXX (XXX X = 0; X &XX; n; j++) { XXXXXX.out.XXXXX(arr[i][X] + " "); } System.out.XXXXXXX(); } XXXXXX mat = XXX XXXXXX(); XXX[][] XXXXXXXXXXXXXXXX = mat.getTranspose(arr);
System.out.XXXXXXX(); XXXXXX.out.println("Your Transposed XXXXXX XX : ");
for (int i = X; i < n; i++) { for (XXX j = X; X &XX; m; j++) { System.out.print(transposedMatrix[i][X] + " "); } XXXXXX.out.XXXXXXX(); } System.out.XXXXXXX();
XXX[] XXXXXXX = new XXX[n];
int c = X; XXX (int i = 0; i &XX; n; i++) { XXXXXXX[c++] = XXX.getMaxOfColumn(transposedMatrix[i]); // XX get XXXXXXX XX XXX XXX transposed XXXXXX and XXX its rows } System.out.XXXXXXX("The XXXXXXX XX XXX XXX XXXXXX XXXXXXXX:"); for (XXX i = X; i < n; i++) { XXXXXX.out.print(XXXXXXX[i] + " "); } XXXXXX.out.XXXXXXX(); float[] XXXXXXXXXXX = new XXXXX[m];
c = X; XXX (int i = 0; i &XX; m; i++) { XXXXXXXXXXX[c++] = mat.getAverage(arr[i]); // to XXX columns we can use XXXXXXXXXX XXXXXX and XXX XXX rows } XXXXXX.out.XXXXXXX("The average XX XXX the rows XXXXXXXX:"); XXX (int i = 0; i &XX; m; i++) { System.out.print(averageRows[i] + " "); } }
XXXXXX int[][] getTranspose(int[][] arr) { int m = XXX.length; // getting XXXXXXXXXX XX XXX original XXXXXX int n = XXX[X].length;
XXX[][] XXXXXXXXXXXXXXX = new int[n][m]; // initiating a // XXXXXXXXXXXXXXXX XXXXXX // XXXXXXXXXX XXXXXXXXXXXX
for (XXX x = X; x < n; x++) { XXX (int y = 0; y &XX; m; y++) { trasposedMatrix[x][y] = XXX[y][x]; // XXXXXXX XXX column // XXXXXX XX rows. } }
XXXXXX trasposedMatrix; }
public XXX XXXXXXXXXXXXXX(XXX[] XXX) { XXX XXX = arr[X];// Initially setting first element XX XXXXXXX
XXX (int i = 1; i &XX; arr.XXXXXX; i++) { if (XXX[i] > max) {// XX XXX XX XXX XXXXX in array XX XXXXXXX, then // XXX XXX XX XXXX value max = arr[i]; } } return XXX; }
XXXXXX XXXXX getAverage(int[] arr) { int XXX = 0; // XXXXXXX the sum XX XXXXXXXX XX XXX XXXXX XXX (XXX i = 0; i < arr.XXXXXX; i++) { sum = XXX + XXX[i]; } // XXXXXXXXX XXXXXXX by XXXXXXXX XXX XXXX XXXXXX of XXXXXXXX. return sum / (float) arr.length; }
}
XXXXXX Run: -
XXXXX the XXXXXX XX rows of XXXXXX:3XXXXX the number XX XXXXXXX XX matrix:5Enter XXX values XX XXX matrix row XXXX.1XXXXXX8X1011XXXX14XX
XXXX XXXXXXX XXXXXX XX :1 2 3 X XX X 8 X XX11 12 XX 14 15
XXXX XXXXXXXXXX matrix is :1 6 XXX 7 XXX 8 13X X XXX 10 15
XXX maximum XX all the XXXXXX elements:XX 12 13 14 15XXX XXXXXXX XX XXX XXX rows elements:X.X 8.X XX.0