Skip to content

Commit a7175d2

Browse files
committed
Basic:- First Solution to Full Numeric Pyramid Printing
1 parent f5ce88f commit a7175d2

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎src/Scaler/Assignments/PatternPrinting.java‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,45 @@ public class PatternPrinting {
66
public static void main(String[] args) {
77
Scanner scanner = new Scanner(System.in);
88
int number = scanner.nextInt();
9+
10+
//------------------------------------------------------------------------
11+
// Star Pattern II
12+
/*
13+
0 0 0 0 1 0 0 0 0
14+
0 0 0 2 3 2 0 0 0
15+
0 0 3 4 5 4 3 0 0
16+
0 4 5 6 7 6 5 4 0
17+
5 6 7 8 9 8 7 6 5
18+
*/
19+
for (int i = 1; i <= number; i++) {
20+
21+
int leftZeroes = (number-i);
22+
int rightZeroes = (number-i);
23+
int numbers = (i*2-1);
24+
25+
for (int j = 1; j <= leftZeroes; j++) {
26+
System.out.print(0 + "_");
27+
}
28+
29+
for (int j = 1; j <= numbers; j++) {
30+
// if (j<numbers){System.out.print(j + "_");}
31+
// else {System.out.print(j);}
32+
if (j<numbers){System.out.print(j + "_");}
33+
else{System.out.print(j);}
34+
}
35+
36+
for (int j = 1; j <= rightZeroes; j++) {
37+
if (j<leftZeroes){System.out.print(0 + "_");}
38+
else {System.out.print(0);}
39+
}
40+
System.out.println();
41+
}
42+
43+
44+
45+
//------------------------------------------------------------------------//
46+
47+
948
//------------------------------------------------------------------------
1049
// Star Pattern II
1150
/*

0 commit comments

Comments
 (0)