forked from srinathr91/TestJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
45 lines (34 loc) · 692 Bytes
/
Test.java
File metadata and controls
45 lines (34 loc) · 692 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
37
38
39
40
41
42
43
44
45
package stickerball_game;
public class Test {
public static int method(int[][] a,int x, int y,int n){
if(x==0 && y==0){
n++;
}
if(a[x][y]==0){
return n;
}
else{
if(x>=1&&y>=0)
n=method(a,x-1, y,n);
if(y>=1&&x>=0)
n=method(a,x, y-1,n);
}
return n;
}
public static void main(String[] args){
int[][] multi = new int[][]{
{ 1, 1, 1, 1,1 },
{ 1, 1, 1, 1,1 },
{ 1, 1, 1, 1,1 },
{ 1, 1, 1, 1,1 },
{ 1, 1, 1, 1,1 }
};
for(int i=0; i<3;i++){
for(int j=0;j<3;j++){
System.out.print(multi[i][j]+"\t");
}
System.out.println();
}
System.out.println(Test.method(multi, 4, 4,0));
}
}