We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0911cea commit 8311a0eCopy full SHA for 8311a0e
Pattern-2/Star_Pattern.java
@@ -0,0 +1,43 @@
1
+/*
2
+Print the following pattern
3
+Pattern for N = 4
4
+
5
+ *
6
+ ***
7
+ *****
8
+ *******
9
+*/
10
11
+import java.util.Scanner;
12
13
+public class Star_Pattern {
14
+ public static void main(String[] args) {
15
16
+ /*
17
+ * Your class should be named Solution.
18
+ * Read input as specified in the question.
19
+ * Print output as specified in the question.
20
+ */
21
22
+ Scanner sc = new Scanner(System.in);
23
+ int n = sc.nextInt();
24
+ int space = n - 1;
25
+ int i = 1;
26
+ while (i <= n) {
27
+ int j = 1;
28
+ space = n - i;
29
+ while (space > 0) {
30
+ System.out.print(" ");
31
+ space--;
32
+ }
33
+ while (j <= ((2 * i) - 1)) {
34
+ System.out.print("*");
35
+ j += 1;
36
37
+ System.out.println("");
38
+ i += 1;
39
40
41
42
43
+}
0 commit comments