File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,4 +19,5 @@ public static void main(String[] args) {
1919 }
2020
2121 }
22+
2223}
Original file line number Diff line number Diff line change 1+ package Pattern_Printing ;
2+
3+ import java .util .Scanner ;
4+
5+ public class Binary_Triangle {
6+ public static void main (String [] args ) {
7+ Scanner sc = new Scanner (System .in );
8+ System .out .println ("Enter a number" );
9+ int n =sc .nextInt ();
10+
11+ for (int i =1 ;i <=n ;i ++) {
12+ for (int j =2 ;j <=i ; j ++) {
13+ if (i ==j || (j +i )%2 ==0 ) {
14+ System .out .print (0 +" " );
15+ }
16+ else {
17+ System .out .print (1 +" " );
18+ }
19+ }
20+ System .out .println ();
21+ }
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ package Pattern_Printing ;
2+
3+ import java .util .Scanner ;
4+
5+ public class Floyd_Triangle {
6+
7+
8+ public static void main (String [] args ) {
9+ Scanner sc = new Scanner (System .in );
10+ System .out .println ("Enter a number" );
11+ int n =sc .nextInt ();
12+ int a =1 ;
13+
14+ for (int i =1 ;i <=n ;i ++) {
15+ for (int j =1 ;j <=i ;j ++) {
16+ System .out .print (a ++ +" " );
17+
18+ }
19+ System .out .println ();
20+ }
21+
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ package Pattern_Printing ;
2+
3+ import java .util .Scanner ;
4+
5+ public class Star_Cross {
6+
7+ public static void main (String [] args ) {
8+ Scanner sc =new Scanner (System .in );
9+ System .out .println ("Enter rows" );
10+ int n =sc .nextInt ();
11+
12+ for (int i =1 ;i <=n ; i ++) {
13+ for (int j =1 ;j <=n ;j ++) {
14+
15+ if (i ==j ||j ==n +1 -i ) {
16+ System .out .print ("* " );
17+
18+ }
19+ else {
20+ System .out .print (" " );
21+ }
22+ }
23+ System .out .println ();
24+ }
25+ }
26+
27+ }
You can’t perform that action at this time.
0 commit comments