-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFullPyramid
More file actions
52 lines (47 loc) · 1.15 KB
/
Copy pathFullPyramid
File metadata and controls
52 lines (47 loc) · 1.15 KB
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
46
47
48
49
50
51
52
public class FullPyramid {
private static int rows=5;
public static void printspace(int space) {
//Termination case + Business logic
if(space==0){
return;
}else{
System.out.print(" ");
}
//Recursive call
printspace(space-1);
}
public static void printstar(int star) {
//Termination case
if(star==0){
return;
}
//Business logic
System.out.print("*");
System.out.print(" ");
//Recursive call
printstar(star-1);
}
public static void printline(int row,int space) {
//Termination case
if(row==0){
return;
}
//Business logic
printspace(row-1);
printstar(space);
System.out.println();
//Recursive call
printline(row-1, space+2);
//Business logic
if(space==9){
return;
}
printspace(row-1);
printstar(space);
System.out.println();
}
public static void main(String[] args) {
printline(rows,1);
System.out.println();
}
}