Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examples;
- import java.util.Random;
- public class Exe {
- static int[][] array = new int[3][2];
- static Random rnd = new Random();
- static String numerosGenerados = "";
- static void generarNumeros()
- {
- for(int i=0 ; i<array.length; i++)
- {
- for(int j=0 ; j<array[i].length; j++)
- {
- int random = rnd.nextInt(101);
- array[i][j] = random;
- numerosGenerados += ""+random+",";
- }
- }
- numerosGenerados = numerosGenerados.substring(0, numerosGenerados.length()-1);
- }
- /**
- *Columnas:
- *{1,2,3},//columna número 0
- *{8,7,0},//columna número 1
- *{10,11,3}//columna número 2
- * @param args
- */
- public static void main(String[] args)
- {
- generarNumeros();
- int num = 0;
- int poscol = 0;
- int posfil = 0;
- for(int i=0 ; i<array.length ; i++)
- {
- for(int j=0 ; j<array[i].length; j++)
- {
- if(i == 0)
- {
- num = array[i][j];
- poscol = i;
- posfil = j;
- }
- else
- {
- if(array[i][j] > num)
- {
- num = array[i][j];
- poscol = i;
- posfil = j;
- }
- }
- }
- }
- System.err.println("Números generados: "+ numerosGenerados);
- System.err.println("El número más grande es "+ num +", posición de la columna:"+poscol+", de la fila: "+ posfil);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement