Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #297 from Saurabhlucifer/add-saurabh
Browse files Browse the repository at this point in the history
butterfly pattern added
  • Loading branch information
Almas-Ali authored Oct 30, 2022
2 parents b6356d9 + c6b93b6 commit 03a98fd
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions Java/Pattern Questions/butterfly.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Github name : Saurabhlucifer
import java.util.*;
public class butterfly{
public static void main(String args[])
{

int i,j;
System.out.println("");
int n=10;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{

System.out.print("* ");

}
int space=2*(n-i);
for(j=1;j<=space;j++)
{
System.out.print(" ");
}
for(j=1;j<=i;j++)
{

System.out.print("* ");
}
System.out.println();
}
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
System.out.print("* ");

}
int space=2*(n-i);
for(j=1;j<=space;j++)
{
System.out.print(" ");
}
for(j=1;j<=i;j++)
{
System.out.print("* ");
}

System.out.println();
}
}
}
//output
//* *
//* * * *
//* * * * * *
//* * * * * * * *
//* * * * * * * * * *
//* * * * * * * * * * * *
//* * * * * * * * * * * * * *
//* * * * * * * * * * * * * * * *
//* * * * * * * * * * * * * * * * * *
//* * * * * * * * * * * * * * * * * * * *
//* * * * * * * * * * * * * * * * * * * *
//* * * * * * * * * * * * * * * * * *
//* * * * * * * * * * * * * * * *
//* * * * * * * * * * * * * *
//* * * * * * * * * * * *
//* * * * * * * * * *
//* * * * * * * *
//* * * * * *
//* * * *
//* *

0 comments on commit 03a98fd

Please sign in to comment.