forked from DHEERAJHARODE/Hacktoberfest2024-Open-source-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiamondShape.java
32 lines (31 loc) · 863 Bytes
/
DiamondShape.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
import java.util.Scanner;
public class DiamondShape {
public static void main(String[] args) {
int i, j, k, temp = 1;
for (i = 0; i < 5; i++) {
for (k = i; k < 4; k++)
System.out.print(" ");
System.out.print("*");
if (i != 0) {
for (j = 1; j <= temp; j++)
System.out.print(" ");
System.out.print("*");
temp += 2;
}
System.out.println();
}
temp-=4;
for(i=0;i<4;i++){
for(k=0;k<=i;k++)
System.out.print(" ");
System.out.print("*");
if(i!=3){
for(j=1;j<=temp;j++)
System.out.print(" ");
System.out.print("*");
temp-=2;
}
System.out.println();
}
}
}