Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Matriz {
- public static void main(String args[]){
- int l, c;
- Scanner leia = new Scanner(System.in);
- System.out.print("Entre com o numero de linhas: ");
- l = leia.nextInt();
- System.out.print("Entre com o numero de colunas: ");
- c = leia.nextInt();
- System.out.println("\nMatriz:");
- matriz(l,c);
- }
- //Funcao que retorna a matriz
- public static void matriz(int l, int c) {
- int mat[][] = new int [l][c];
- for(int i=0; i<l; i++){
- for(int j=0; j<c; j++){
- mat[i][j] = (int)(Math.random() * 10);
- System.out.printf("%d\t", mat[i][j]);
- } System.out.print("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement