forked from Abraarkhan/Java_Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiamond_shape.java
42 lines (38 loc) · 915 Bytes
/
diamond_shape.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
// Java program to Print Diamond Star Pattern
// Using do-while loop
import java.io.*;
public class GFG {
public static void main(String[] args)
{
int number = 7;
int m = 1;
int n;
do {
n = 1;
do {
System.out.print(" ");
}
while (++n <= number - m + 1);
n = 1;
do {
System.out.print("*");
}
while (++n <= m * 2 - 1);
System.out.println();
}
while (++m <= number);
m = number - 1;
do {
n = 1;
do {
System.out.print(" ");
} while (++n <= number - m + 1);
n = 1;
do {
System.out.print("*");
} while (++n <= m * 2 - 1);
System.out.println();
}
while (--m > 0);
}
}