Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package matriz;
- import java.util.Random;
- public class ex2loiane {
- public static void main(String[] args) {
- int [][] matriz = new int [10][10];
- Random numero = new Random();
- // gerar matriz randomica
- for(int i = 0; i < matriz.length; i++){
- for(int j = 0; j < matriz[i].length; j++){
- matriz[i][j] = numero.nextInt(100);
- }
- }
- // imprimir matriz
- for(int i = 0; i < matriz.length; i++){
- for(int j = 0; j < matriz[i].length; j++){
- System.out.print(matriz[i][j] + " ");
- }
- System.out.println();
- }
- // na linha 5
- int maiorL5 = 0;
- int menorL5 = Integer.MAX_VALUE;
- for(int i = 0; i < matriz[5].length; i++){
- if(matriz[5][i] > maiorL5){
- maiorL5 = matriz[5][i];
- }
- if(matriz[5][i] < menorL5){
- menorL5 = matriz[5][i];
- }
- }
- System.out.println("maior valor da linha 5: "+maiorL5);
- System.out.println("menor valor da linha 5: "+menorL5);
- int maiorC7 = 0;
- int menorC7 = Integer.MAX_VALUE;
- for(int i = 0; i < matriz.length; i++){
- if(matriz[i][7] > maiorC7){
- maiorC7 = matriz[i][7];
- }
- if(matriz[i][7] < menorC7){
- menorC7 = matriz[i][7];
- }
- }
- System.out.println("maior valor da coluna 7: "+maiorC7);
- System.out.println("menor valor da coluna 7: "+menorC7);
- }
- /* César N. */
- }
- //Gere e imprima uma matriz M 10x10 com valores aleatorios entre 0 e 9.
- //Após isso indique qual é o maior e o menor valor da linha 5
- //E qual é o maior e o menor valor da linha 7.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement