Skip to content

Commit 85908c8

Browse files
committed
Basic:- Solution to Pattern Printing 2
1 parent 51d037c commit 85908c8

1 file changed

Lines changed: 27 additions & 10 deletions

File tree

‎src/Scaler/Assignments/PatternPrinting.java‎

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,38 @@ public static void main(String[] args) {
6565
// }
6666
//------------------------------------------------------------------------
6767

68+
// for (int i = 1; i <= number; i++) {
69+
//
70+
// /*Spaces*/
71+
// for (int spaces = 1; spaces <= i-1; spaces++) {
72+
// System.out.print("_");
73+
// }
74+
// /*Stars*/
75+
// for (int stars = 1; stars <= number-i; stars++) {
76+
// System.out.print("*");
77+
// }
78+
//
79+
// System.out.println();
80+
// }
81+
82+
//------------------------------------------------------------------------
83+
84+
/*Pattern 6
85+
1
86+
2 3
87+
4 5 6
88+
7 8 9 10
89+
* */
90+
91+
int value = 1;
6892
for (int i = 1; i <= number; i++) {
6993

70-
/*Spaces*/
71-
for (int spaces = 1; spaces <= i-1; spaces++) {
72-
System.out.print("_");
73-
}
74-
/*Stars*/
75-
for (int stars = 1; stars <= number-i; stars++) {
76-
System.out.print("*");
94+
for (int j = 1; j <= i; j++) {
95+
System.out.print(value + " ");
96+
value = value + 1;
7797
}
78-
7998
System.out.println();
8099
}
81100

82-
//------------------------------------------------------------------------
83-
84101
}
85102
}

0 commit comments

Comments
 (0)