forked from Vishal21121/Patterns-different-language
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPattern19.java
42 lines (40 loc) · 944 Bytes
/
Pattern19.java
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
import java.util.Scanner;
// *
// * *
// * *
// * *
// * *
// * *
// * *
// * *
// *
public class Pattern19 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the number:");
int n = in.nextInt();
int Corep;
int spaceChange;
for (int row = 1; row <= 2 * n - 1; row++)
{
Corep = row <= n ? row : 2 * n - row;
spaceChange = row <= n ? n - row + 1 : (row - n) + 1;
for (int k = 1; k <= spaceChange; k++)
{
System.out.print(" ");
}
for (int col = 1; col <= Corep; col++)
{
if (col == 1 || col == Corep)
{
System.out.print("* ");
}
else
{
System.out.print(" ");
}
}
System.out.println();
}
}
}