Output :
X X X X X X X X X X --------------------- X X X X X X X X X XJAVA Code:
public class HelloWorld {
static int count = 0;
public static void print(int i, int j) {
if (i <= 0 || j < 0 ) return;
System.out.print("X ");
print(i, j - 1);
if (j == 0) {
count++;
System.out.println();
print(i - 1, count);
}
}
public static void print2(int i, int j) {
if (i <= 0 || j < 0 ) return;
System.out.print("X ");
print2(i, j - 1);
if (j == 0) {
System.out.println();
print2(i - 1, i-2);
}
}
public static void main(String[] args) {
//System.out.println("Hello World2");
print(4, 0);
System.out.println("---------------------");
print2(4, 3);
}
}