Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a3da25d

Browse files
⭐Added Right Half Pyramid Pattern
1 parent 2f47d2b commit a3da25d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
364 Bytes
Binary file not shown.

‎src/PyramidPatterns.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ public static void main(String[] args) {
1414
+-----------------------+""");
1515
invertedHalfPyramid(length);
1616

17+
System.out.println("""
18+
+-----------------------+
19+
| Right Half Pyramid |
20+
+-----------------------+""");
21+
rightHalfPyramid(length);
22+
1723
}
1824

1925
public static void halfPyramid(int length) {
@@ -31,4 +37,14 @@ public static void invertedHalfPyramid(int length) {
3137
System.out.println();
3238
}
3339
}
40+
41+
public static void rightHalfPyramid(int length) {
42+
for(int i=1; i<=length; i++){
43+
for (int space=1; space<=(length-i) * 2; space++)
44+
System.out.print(" ");
45+
for (int j=1; j<=i; j++)
46+
System.out.print("* ");
47+
System.out.println();
48+
}
49+
}
3450
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /