3
You had to create a 5x5 array by printing random characters from the ASCII table.
public class ExercicioClass01g {
static Scanner ler = new Scanner(System.in);
public static char mat[][] = new char[5][5];
public static void gera(int lin, int col){
Random gerador = new Random();
int ctlin,ctcol;
for(ctlin=0;ctlin<lin;ctlin++)
for(ctcol=0;ctcol<col;ctcol++)
mat[ctlin][ctcol]=(char)(gerador.nextInt(25)+65);
}
public static void exibe(int lin, int col){
int ctlin,ctcol;
for(ctlin=0;ctlin<lin;ctlin++){
for(ctcol=0;ctcol<col;ctcol++)
System.out.print(mat[ctlin][ctcol]+" ");
System.out.println();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
gera(5, 5);
exibe(5,5);
}
I managed to print but I can’t do the lyrics (char
) do not repeat in the matrix.
Thank you very much, it worked :D
– Francine Stivanin
@Francinestivanin Take a look at the [tour] You can accept the answer and vote for it and any other posts on the site as well.
– Maniero