Matriz, gotoxy y scanner AYUDA CON CODIGO
Publicado por jam (1 intervención) el 21/05/2024 04:57:40
Intento hacer un codigo que al agregar los datos de una matriz[2][2], se agreguen de esta manera:
5 7
21 13
y eso sea todo en el codigo, mi profesor nos enseño como usar un metodo gotoxy en java para asi poder leer dos variables en una misma linea, pero por mas que busco no encuentro como,algun consejo?
public static int[][] noo = new int[2][2];
public static Scanner leer=new Scanner(System.in);
public static void main(String[] args) {
aaa();
}
public static void aaa(){
for (int f = 0; f < noo.length; f++) {
for (int c = 0; c < noo.length; c++) {
noo[f][c]=leer.nextInt();
System.out.print(" ");
gotoxy(10,0);
}
gotoxy(0,1);
}
}
public static void gotoxy(int x, int y){
for (int i = 0; i <x; i++) {
System.out.print(" ");
for (int j = 0; j < y; j++) {
System.out.print("\n");
}
}
}
5 7
21 13
y eso sea todo en el codigo, mi profesor nos enseño como usar un metodo gotoxy en java para asi poder leer dos variables en una misma linea, pero por mas que busco no encuentro como,algun consejo?
public static int[][] noo = new int[2][2];
public static Scanner leer=new Scanner(System.in);
public static void main(String[] args) {
aaa();
}
public static void aaa(){
for (int f = 0; f < noo.length; f++) {
for (int c = 0; c < noo.length; c++) {
noo[f][c]=leer.nextInt();
System.out.print(" ");
gotoxy(10,0);
}
gotoxy(0,1);
}
}
public static void gotoxy(int x, int y){
for (int i = 0; i <x; i++) {
System.out.print(" ");
for (int j = 0; j < y; j++) {
System.out.print("\n");
}
}
}
Valora esta pregunta
![Me gusta: Está pregunta es útil y esta clara Me gusta: Está pregunta es útil y esta clara](/img/img.png?11.51)
![NO me gusta: Está pregunta no esta clara o no es útil No me gusta: Está pregunta no esta clara o no es útil](/img/img.png?11.51)
0