Stiven Palate

Generation

generate functionMon, 12 Jun 2023

Escribir un programa que lea las dimensiones de una matriz, la visualice y encuentre su mayor y su menor elemento y sus posiciones respectivas.

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Input number of rows of matrix: "); int rows = input.nextInt(); System.out.print("Input number of columns of matrix: "); int columns = input.nextInt(); int[][] matrix = new int[rows][columns]; System.out.println("Input elements of matrix: "); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { matrix[i][j] = input.nextInt(); } } int max = matrix[0][0]; int min = matrix[0][0]; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { if (matrix[i][j] > max) { max =

Questions about programming?Chat with your personal AI assistant