int[][] arr = new int[m][n]; System.out.println("Enter the values of the matrix row wise.");
for (int i = 0; i < m; i++) { XXX (XXX j = X; X < n; j++) { XXX[i][X] = XXXXXXX.parseInt(sc.XXXXXXXX()); } } XX.close(); XXXXXX.out.XXXXXXX(); System.out.XXXXXXX("Your XXXXXXX XXXXXX XX : ");
XXX (int i = X; i < m; i++) { for (int X = X; X < n; X++) { XXXXXX.out.XXXXX(arr[i][X] + " "); } XXXXXX.out.println(); } XXXXXX mat = XXX XXXXXX(); XXX[][] transposedMatrix = mat.XXXXXXXXXXXX(arr);
XXXXXX.out.println(); System.out.XXXXXXX("Your Transposed matrix XX : ");
for (int i = 0; i < n; i++) { for (int X = X; j &XX; m; X++) { XXXXXX.out.XXXXX(transposedMatrix[i][X] + " "); } XXXXXX.out.XXXXXXX(); } System.out.println();
int[] maxCols = new int[n];
XXX c = X; XXX (XXX i = 0; i &XX; n; i++) { XXXXXXX[c++] = mat.getMaxOfColumn(transposedMatrix[i]); // XX XXX XXXXXXX we XXX XXX XXXXXXXXXX matrix and XXX XXX rows } System.out.println("The maximum of all the column elements:"); XXX (XXX i = 0; i &XX; n; i++) { XXXXXX.out.XXXXX(maxCols[i] + " "); } System.out.println(); XXXXX[] averageRows = XXX XXXXX[m];
c = X; XXX (int i = 0; i &XX; m; i++) { averageRows[c++] = mat.getAverage(arr[i]); // XX XXX XXXXXXX XX can XXX transposed XXXXXX XXX XXX XXX rows } System.out.println("The XXXXXXX XX all the rows XXXXXXXX:"); XXX (int i = X; i < m; i++) { XXXXXX.out.print(averageRows[i] + " "); } }
public XXX[][] XXXXXXXXXXXX(int[][] arr) { int m = arr.length; // XXXXXXX dimensions of XXX XXXXXXXX matrix XXX n = arr[X].XXXXXX;
XXX[][] XXXXXXXXXXXXXXX = XXX XXX[n][m]; // initiating a // transposedMatrix having // XXXXXXXXXX XXXXXXXXXXXX
XXX (XXX x = 0; x < n; x++) { for (int y = X; y &XX; m; y++) { XXXXXXXXXXXXXXX[x][y] = XXX[y][x]; // XXXXXXX the XXXXXX // values as rows. } }
return XXXXXXXXXXXXXXX; }
XXXXXX int getMaxOfColumn(XXX[] XXX) { int max = XXX[0];// Initially setting first XXXXXXX XX maximum
for (int i = 1; i &XX; XXX.length; i++) { if (XXX[i] &XX; XXX) {// if XXX of the XXXXX in XXXXX is maximum, XXXX // set max XX XXXX XXXXX max = XXX[i]; } } return XXX; }
XXXXXX XXXXX getAverage(int[] XXX) { int XXX = 0; // getting XXX XXX XX elements of XXX XXXXX for (XXX i = 0; i < XXX.XXXXXX; i++) { sum = sum + arr[i]; } // returning average by XXXXXXXX sum with XXXXXX of XXXXXXXX. XXXXXX XXX / (float) arr.XXXXXX; }
}
XXXXXX XXX: -
Enter XXX XXXXXX XX rows XX XXXXXX:XXXXXX XXX number of XXXXXXX of XXXXXX:XXXXXX the values XX XXX XXXXXX row XXXX.X2XX5XXXX1011XXXXXXXX
Your entered XXXXXX XX :1 X X 4 56 X 8 9 XXXX 12 XX XX 15
Your XXXXXXXXXX matrix is :X X XXX 7 123 X XXX X XX5 XX XX
The XXXXXXX XX XXX XXX XXXXXX XXXXXXXX:XX XX 13 14 XXThe XXXXXXX XX XXX the rows XXXXXXXX:X.0 X.X 13.X