-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatternstar.java
More file actions
34 lines (33 loc) · 810 Bytes
/
patternstar.java
File metadata and controls
34 lines (33 loc) · 810 Bytes
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
import java.util.Scanner;
public class patternstar {
public static void main(String[] args)
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
for(int i=0;i<n/2+1;i++)
{
for(int k=i;k<n/2;k++)
{
System.out.print(" ");
}
for(int j=0;j<2*i+1;j++)
{
System.out.print("*");
}
System.out.println();
}
for(int i=0;i<n/2;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print(" ");
}
for(int k=2*i;k<n-2;k++)
{
System.out.print("*");
}
System.out.println();
}
}
}