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