Skip to content

Commit

Permalink
Merge pull request #9 from AmaanSayyed/master
Browse files Browse the repository at this point in the history
Happy Hacktoberfest 2023
  • Loading branch information
Yashkapure06 authored Oct 14, 2023
2 parents 89e19d0 + 32a80aa commit e02fe01
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,17 @@
* *
* *
*****************
```
```
15.Hollow Diamond Pattern
```
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
```
43 changes: 43 additions & 0 deletions src/HollowDiamondPattern/HollowDiamondRectangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import java.util.Scanner;


public class HollowDiamondRectangle {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int i=0, j=0;
int n = sc.nextInt();
// upper half of the pattern
for(i = 0; i < n; i++)
{
for(j = 0; j < (2 * n); j++)
{
if(i + j <= n - 1) // upper left triangle
System.out.print("*");
else
System.out.print(" ");
if((i + n) <= j) // upper right triangle
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
// bottom half of the pattern
for(i = 0; i < n; i++)
{
for(j = 0; j < (2 * n); j++)
{
if(i >= j) // bottom left triangle
System.out.print("*");
else
System.out.print(" ");
if(i >= (2 * n - 1) - j) // bottom right triangle
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}

0 comments on commit e02fe01

Please sign in to comment.