-
Notifications
You must be signed in to change notification settings - Fork 2
/
Star Pattern
63 lines (38 loc) · 804 Bytes
/
Star Pattern
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
53
54
55
56
57
58
59
60
61
62
63
Print the following pattern
Sample Input 1 :
3
Sample Output 1 :
*
***
*****
Sample Input 2 :
4
Sample Output 2 :
*
***
*****
*******
JAVA CODE:-
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Your class should be named Solution.
* Read input as specified in the question.
* Print output as specified in the question.
*/
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int i=1;i<=n;i++)
{
for(int j=i;j<n;j++)
{
System.out.print(" ");
}
for(int k=1;k<=2*i-1;k++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}