-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecursividad3.java
More file actions
36 lines (29 loc) · 816 Bytes
/
Recursividad3.java
File metadata and controls
36 lines (29 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class Recursividad3 {
/**
* Cómo recorrer un array con recursividad
*
*/
public static void main(String[] args){
int[][] array = {
{2,5,4},
{65,2,87},
{23,1,9}
};
recorriendoArray(array, 0, 0);
}
public static void recorriendoArray(int[][] array, int i, int j){
System.out.print(array[i][j] + " ");
if(i != array.length - 1 || j != array[i].length - 1){
if(j == array[i].length - 1){
//Salto de linea dentro del array
i++;
j = 0;
System.out.println(" ");
} else{
//Salto de columna
j++;
}
recorriendoArray(array, i, j);
}
}
}