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 keyboard = new Scanner(System.in); int rows, cols; System.out.println("Rows: "); rows = keyboard.nextInt(); System.out.println("Cols: "); cols = keyboard.nextInt(); int[][] matrix = new int[rows][cols]; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { System.out.println("Enter value for position " + i + " " + j); matrix[i][j] = keyboard.nextInt(); } } keyboard.close(); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { System.out.print(matrix[i][j] + " "); } System.out

Questions about programming?Chat with your personal AI assistant