Skip to content

Commit 51d037c

Browse files
committed
Basic:- Solution to Pattern Printing 1
1 parent e1f09b9 commit 51d037c

1 file changed

Lines changed: 59 additions & 6 deletions

File tree

‎src/Scaler/Assignments/PatternPrinting.java‎

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,67 @@ public static void main(String[] args) {
1919
// System.out.println("");
2020
// }
2121

22-
for (int i=1; i < number; i++) {
23-
System.out.print("*");
24-
int spaces = number-i;
22+
//------------------------------------------------------------------------
23+
/*
24+
*___*
25+
*__*
26+
*_*
2527
26-
for (int j = 1; j <= spaces; j++) {
27-
System.out.print(" ");
28+
*/
29+
// for (int i=1; i < number; i++) {
30+
// System.out.print("*");
31+
// int spaces = number-i;
32+
//
33+
// for (int j = 1; j <= spaces; j++) {
34+
// System.out.print(" ");
35+
// }
36+
// System.out.println("*");
37+
// }
38+
39+
//------------------------------------------------------------------------
40+
41+
//------------------------------------------------------------------------
42+
/*
43+
44+
______*
45+
_____**
46+
____***
47+
___****
48+
__*****
49+
_******
50+
*******
51+
52+
*/
53+
54+
// for (int rows = 1; rows <= number; rows++) {
55+
//// System.out.print(number);
56+
// int spaces = number-1;
57+
// for (int j = 1; j <= spaces; j++) {
58+
// System.out.print("_");
59+
// }
60+
// int stars = rows;
61+
// for (int i = 1; i <= stars; i++) {
62+
// System.out.print("*");
63+
// }
64+
// System.out.println("");
65+
// }
66+
//------------------------------------------------------------------------
67+
68+
for (int i = 1; i <= number; i++) {
69+
70+
/*Spaces*/
71+
for (int spaces = 1; spaces <= i-1; spaces++) {
72+
System.out.print("_");
2873
}
29-
System.out.println("*");
74+
/*Stars*/
75+
for (int stars = 1; stars <= number-i; stars++) {
76+
System.out.print("*");
77+
}
78+
79+
System.out.println();
3080
}
81+
82+
//------------------------------------------------------------------------
83+
3184
}
3285
}

0 commit comments

Comments
 (0)