Skip to content

Commit d09f77b

Browse files
authored
Created PatternMatching Program
1 parent 0fff0fb commit d09f77b

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

PatternMaking

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* For n =4 the output should be
2+
3+
*
4+
* *
5+
* * *
6+
* * * *
7+
* * *
8+
* *
9+
*
10+
11+
*/
12+
13+
import java.util.Scanner;
14+
15+
public class Solution {
16+
17+
public static void main(String[] args) {
18+
Scanner s = new Scanner(System.in);
19+
int n = s.nextInt();
20+
for (int i = 1; i <= n; i++) {
21+
for (int stars = 1; stars <= i; stars++) {
22+
System.out.print("* ");
23+
}
24+
System.out.println();
25+
}
26+
for (int i = 1; i < n; i++) {
27+
for (int stars = n - 1; stars >= i; stars--) {
28+
System.out.print("* ");
29+
}
30+
System.out.println();
31+
}
32+
}
33+
34+
}

0 commit comments

Comments
 (0)