Skip to content

Commit

Permalink
pattern problems solved
Browse files Browse the repository at this point in the history
  • Loading branch information
riteshgaigawali committed Aug 2, 2024
1 parent e124498 commit 472a9dc
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
3 changes: 1 addition & 2 deletions problems/Pattern03.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*Print the following pattern: Hollow Rectangle
/*Print the following pattern: Half Peramid
*
* *
Expand All @@ -13,7 +13,6 @@ public class Pattern03 {

public static void main(String[] args) {
int rows = 4;
int columns = 4;

for (int i = 1; i <= rows; i++) {

Expand Down
27 changes: 27 additions & 0 deletions problems/Pattern04.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*Print the following pattern: Inverted Half Peramid
* * * *
* * *
* *
*
*/

package problems;

public class Pattern04 {

public static void main(String[] args) {
int rows = 4;

for (int i = rows; i >= 1; i--) {

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

System.out.println();
}
}

}
28 changes: 28 additions & 0 deletions problems/Pattern05.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*Print the following pattern: Inverted Half Peramid
*
* *
* * *
* * * *
*/

package problems;

public class Pattern05 {

public static void main(String[] args) {
int rows = 4;

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

}
26 changes: 26 additions & 0 deletions problems/Pattern06.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*Print the following pattern: Inverted Half Peramid
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
*/

package problems;

public class Pattern06 {

public static void main(String[] args) {
int rows = 5;

for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + " ");
}
System.out.println();
}
}

}

0 comments on commit 472a9dc

Please sign in to comment.