Skip to content

Commit

Permalink
Merge pull request #4 from 6736-shafi/master
Browse files Browse the repository at this point in the history
updated pattern12
  • Loading branch information
Yashkapure06 authored Oct 1, 2023
2 parents e024b0c + 95280fb commit b4989b3
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1695808131207</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,28 @@
*
```
12 Sandglass Star Pattern
```
* * * * *
* * * *
* * *
* *
*
*
* *
* * *
* * * *
* * * * *
```
13.Alphabet Star Pattern
```
****
* *
* *
* *
*****
* *
* *
* *
* *
```
23 changes: 23 additions & 0 deletions src/AlphabetStarPattern/AlphabetStarPattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package AlphabetStarPattern;

public class AlphabetStarPattern {
public static void main(String[] args) {
int i, j, n = 8;
// Outer for loop for number of lines
for (i = 0; i <= n; i++) {
// Inner for loop for logic execution
for (j = 0; j <= n / 2; j++) {
// prints two vertical lines
if ((j == 0 || j == n / 2) && i != 0 ||
// print first line of alphabet
i == 0 && j != n / 2 ||
// prints middle line
i == n / 2)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
31 changes: 31 additions & 0 deletions src/SandglassStarPattern/SandglassStarPattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package SandglassStarPattern;

import java.util.Scanner;

public class SandglassStarPattern {
public static void main(String[] args) {
int i, j, k, n;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of rows you want to print: ");
n = sc.nextInt();
for (i = 0; i <= n - 1; i++) {
for (j = 0; j < i; j++) {
System.out.print(" ");
}
for (k = i; k <= n - 1; k++) {
System.out.print("*" + " ");
}
System.out.println("");
}
for (i = n - 1; i >= 0; i--) {
for (j = 0; j < i; j++) {
System.out.print(" ");
}
for (k = i; k <= n - 1; k++) {
System.out.print("*" + " ");
}
System.out.println("");
}
sc.close();
}
}

0 comments on commit b4989b3

Please sign in to comment.