|
14 | 14 | {8, 12}, {12, 16} and {16, 20} |
15 | 15 | */ |
16 | 16 | //http://www.geeksforgeeks.org/count-pairs-difference-equal-k/ |
17 | | - |
18 | | -public class MatrixCount { |
19 | | - |
20 | | - public void check (int i, int j, int m, int n, int nexti, int nextj){ |
21 | | - if(i==m-1){ |
22 | | - for(int index=0; index<n-nextj;index++){ |
23 | | - System.out.print(i); |
24 | | - System.out.print(j+index); |
25 | | - System.out.print(" "); |
26 | | - } |
27 | | - System.out.println(); |
28 | | - return; |
29 | | - } |
30 | | - if(j==n-1){ |
31 | | - for(int index=0; index<m-nexti;index++){ |
32 | | - System.out.print(i+index); |
33 | | - System.out.print(j); |
34 | | - System.out.print(" "); |
35 | | - } |
36 | | - System.out.println(); |
37 | | - return; |
38 | | - } |
39 | | - |
40 | | - this.check(i+1, j, m, n, nexti+1, nextj); |
41 | | - this.check(i, j+1, m, n, nexti, nextj+1); |
42 | | - |
43 | | - /*if(i>=n-1 && j<m-1){ |
44 | | - System.out.print(i); |
45 | | - System.out.print(j+" "); |
46 | | - this.check(i, j+1, m, n); |
47 | | - |
48 | | - //System.out.println(0); |
49 | | - } |
50 | | - if(j>=m-1 && i<n-1){ |
51 | | - System.out.print(i); |
52 | | - System.out.print(j+" "); |
53 | | - this.check(i+1,j,m,n); |
54 | | - |
55 | | - } |
56 | | - if(i<n-1 && j <m-1){ |
57 | | - System.out.print(i); |
58 | | - System.out.print(j+" "); |
59 | | - this.check(i+1,j,m,n); |
60 | | - System.out.print(i); |
61 | | - System.out.print(j+" "); |
62 | | - this.check(i,j+1,m,n); |
63 | | - } |
64 | | - else { |
65 | | - System.out.println(11); |
66 | | - }*/ |
67 | | - } |
68 | | - /** |
69 | | - * @param args |
70 | | - */ |
71 | | - public static void main(String[] args) { |
72 | | - // TODO Auto-generated method stub |
73 | | - |
74 | | - int m = 10; |
75 | | - int n =5; |
76 | | - /*double [][] matrix = new double [10][5]; |
77 | | - int i; |
78 | | - int j; |
79 | | - for(i=0;i<10;i++){ |
80 | | - for (j=0;j<5;j++){ |
81 | | - matrix[i][j] = 1; |
82 | | - //System.out.println(matrix[i][j]); |
83 | | - } |
84 | | - }*/ |
85 | | - MatrixCount mc = new MatrixCount(); |
86 | | - mc.check(0, 0, 3, 2,1,1); |
87 | | - |
88 | | - } |
89 | | - |
90 | | -} |
0 commit comments