Skip to content

Commit f27c3b3

Browse files
Merge pull request #277 from Vedansh-Keshari/Vedansh1
Solution to Inner Diamond problem
2 parents 473a4db + 30c1bab commit f27c3b3

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Write a program to print a diamond void on a 7 x 7 grid matrix
2+
class Inner_Diamond{
3+
public static void main(String args[]){
4+
5+
6+
7+
8+
9+
for(int x=0;x<7;x++){ //to iterate the rows
10+
for(int y=0;y<7;y++){ //to iterate the columns
11+
if(x+y>=3 && x+y<=9 && y-x<=3 && y-x>=-3){ //to make the area of the diamond with the equations of the boundary lines
12+
System.out.print(" "); //to print spaces wherever necessary
13+
}
14+
else{
15+
System.out.print("*"); //to print asterisks wherever necessary
16+
}
17+
}
18+
System.out.println(); //to change rows after completion of all columns in a particular row
19+
}
20+
21+
22+
23+
}
24+
}

0 commit comments

Comments
 (0)