Skip to content

Commit 6ead9ca

Browse files
Merge pull request #286 from Vedansh-Keshari/Vedansh123
Solution for Outer Diamond
2 parents 21fc717 + 8aa93ff commit 6ead9ca

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"java.project.sourcePaths": [
3+
"Sorting",
34
"Number Theory",
45
"Basic Codes",
5-
"Sorting"
6+
"Pattern_Printing"
67
]
78
}
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 Outer_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 asterisks wherever necessary
13+
}
14+
else{
15+
System.out.print(" "); //to print spaces 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)