Stiven Palate

Generation

generate functionSun, 11 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.

// Java program to find largest and smallest // elements in a matrix import java.io.*; class GFG { static void findLargestAndSmallest(int matrix[][], int row, int col) { int largest = Integer.MIN_VALUE; int smallest = Integer.MAX_VALUE; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (matrix[i][j] > largest) { largest = matrix[i][j]; } if (matrix[i][j] < smallest) { smallest = matrix[i][j]; } } } System.out.println("Largest element : " + largest); System.out.println("Smallest element : " + smallest); } // driver code public static void main (String[] args) { int matrix[][] = {

Questions about programming?Chat with your personal AI assistant