File tree 9 files changed +327
-0
lines changed
9 files changed +327
-0
lines changed Original file line number Diff line number Diff line change
1
+ Subproject commit 86b52e028ccbdfa4d44f7c94e2362b9c9629c85a
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package patterns ;
7
+
8
+ /**
9
+ *
10
+ * @author SPREEHA DUTTA
11
+ */
12
+ public class pattern1 {
13
+ public static void main (String []args )
14
+ {
15
+ int i ,j ;
16
+ for (i =1 ;i <=5 ;i ++)
17
+ {
18
+ for (j =1 ;j <=i ;j ++)
19
+ {
20
+ System .out .print (j );
21
+ }
22
+ System .out .println ();
23
+ }
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package patterns ;
7
+
8
+ /**
9
+ *
10
+ * @author SPREEHA DUTTA
11
+ */
12
+ public class pattern2 {
13
+ public static void main (String []args )
14
+ {
15
+ int i ,j ;int k =1 ;
16
+ for (i =1 ;i <=4 ;i ++)
17
+ {
18
+ for (j =1 ;j <=i ;j ++)
19
+ {
20
+ System .out .print (k );
21
+ k ++;
22
+ }
23
+ System .out .println ();
24
+ }
25
+ }
26
+
27
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package patterns ;
7
+
8
+ /**
9
+ *
10
+ * @author SPREEHA DUTTA
11
+ */
12
+ public class pattern3 {
13
+ public static void main (String []args )
14
+ {
15
+ int i ,j ;int k =0 ;
16
+ int t =5 /2 ;
17
+ t ++;
18
+ for (i =1 ;i <=5 ;i ++)
19
+ {
20
+ if (i <=t )
21
+ k ++;
22
+ else
23
+ k --;
24
+ for (j =1 ;j <=k ;j ++)
25
+ {
26
+ System .out .print (j );
27
+ }
28
+ System .out .println ();
29
+ }
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package patterns ;
7
+
8
+ /**
9
+ *
10
+ * @author SPREEHA DUTTA
11
+ */
12
+ public class pattern4 {
13
+ public static void print (int s ,int p )
14
+ {
15
+ int i ,j ;int t ;
16
+ if (p <=5 )
17
+ {
18
+ for (i =1 ;i <=s ;i ++)
19
+ System .out .print (' ' );
20
+ t =p ;
21
+ for (j =1 ;j <=p ;j ++)
22
+ {
23
+ System .out .print (t );
24
+ t ++;
25
+ }
26
+ t -=2 ;
27
+ for (j =1 ;j <p ;j ++)
28
+ {
29
+ System .out .print (t );
30
+ t --;
31
+ }
32
+ System .out .println ();
33
+ s --;
34
+ p ++;
35
+ print (s ,p );
36
+ }
37
+ else
38
+ return ;
39
+ }
40
+ public static void main (String []args )
41
+ {
42
+ print (4 ,1 );
43
+ }
44
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package patterns ;
7
+
8
+ /**
9
+ *
10
+ * @author SPREEHA DUTTA
11
+ */
12
+ public class pattern5 {
13
+ public static void main (String []args )
14
+ {
15
+ int n =4 ;
16
+ int i ,j ;int k =0 ;int p =(n *2 -1 );
17
+ for (int t =1 ;t <=n ;t ++)
18
+ {
19
+ for (j =1 ;j <=k ;j ++)
20
+ System .out .print (' ' );
21
+ k ++;
22
+ for (i =1 ;i <=p ;i ++)
23
+ {
24
+ System .out .print ('*' );
25
+ }
26
+ p -=2 ;
27
+ System .out .println ();
28
+ }
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package patterns ;
7
+
8
+ /**
9
+ *
10
+ * @author SPREEHA DUTTA
11
+ */
12
+ public class pattern6 {
13
+ static int n =3 ;
14
+ public static void print (int k ,int i )
15
+ {
16
+ int j ;
17
+ for (j =1 ;j <=k ;j ++)
18
+ System .out .print (' ' );
19
+ for (j =1 ;j <=i ;j ++)
20
+ System .out .print ('*' );
21
+ //System.out.println();
22
+ }
23
+ public static void printdown (int k ,int i )
24
+ {
25
+ int j ;
26
+ for (j =1 ;j <=k ;j ++)
27
+ System .out .print (' ' );
28
+ for (j =1 ;j <=i ;j ++)
29
+ System .out .print ('*' );
30
+ //System.out.println();
31
+ }
32
+ public static void printrow (int i )
33
+ {
34
+ int k ;int j ;
35
+ k =n -i ;
36
+ while (i <=n )
37
+ {
38
+ print (k ,i );
39
+ k --;
40
+ i +=2 ;
41
+ System .out .println ();
42
+ }
43
+ //k++;
44
+ while (i >=1 )
45
+ {
46
+ printdown (k ,i );
47
+ k ++;
48
+ i -=2 ;
49
+ System .out .println ();
50
+ }
51
+ }
52
+ public static void main (String []args )
53
+ {
54
+ printrow (1 );
55
+ }
56
+
57
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package patterns ;
7
+
8
+ /**
9
+ *
10
+ * @author SPREEHA DUTTA
11
+ */
12
+ public class pattern7 {
13
+ public static void main (String []args )
14
+ {
15
+ int n =3 ;
16
+ int i ,j ,t ,k ;int l =1 ;
17
+ t =n *2 +1 ;
18
+ for (i =n ;i >=1 ;i --)
19
+ {
20
+ k =t -2 *i ;
21
+ for (j =i ;j >=1 ;j --)
22
+ {
23
+ System .out .print ('*' );
24
+ }
25
+ l =1 ;
26
+ while (l <=k )
27
+ {
28
+ System .out .print (' ' );
29
+ l ++;
30
+ }
31
+ //System.out.print(' ');
32
+ for (j =1 ;j <=i ;j ++)
33
+ System .out .print ('*' );
34
+ System .out .println ();
35
+ }
36
+
37
+ for (i =1 ;i <=n ;i ++)
38
+ {
39
+ k =t -2 *i ;
40
+ for (j =i ;j >=1 ;j --)
41
+ {
42
+ System .out .print ('*' );
43
+ }
44
+ l =1 ;
45
+ while (l <=k )
46
+ {
47
+ System .out .print (' ' );
48
+ l ++;
49
+ }
50
+ for (j =1 ;j <=i ;j ++)
51
+ System .out .print ('*' );
52
+ System .out .println ();
53
+ }
54
+ }
55
+
56
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package patterns ;
7
+
8
+ /**
9
+ *
10
+ * @author SPREEHA DUTTA
11
+ */
12
+ public class pattern8 {
13
+ public static void main (String []args )
14
+ {
15
+ int n =3 ;
16
+ int i ,j ,t ,k ;int l =1 ;
17
+ t =n *2 ;
18
+ for (i =1 ;i <=n ;i ++)
19
+ {
20
+ k =t -2 *i ;
21
+ for (j =i ;j >=1 ;j --)
22
+ {
23
+ System .out .print ('*' );
24
+ }
25
+ l =1 ;
26
+ while (l <=k )
27
+ {
28
+ System .out .print (' ' );
29
+ l ++;
30
+ }
31
+ for (j =1 ;j <=i ;j ++)
32
+ System .out .print ('*' );
33
+ System .out .println ();
34
+ }
35
+
36
+ for (i =n ;i >=1 ;i --)
37
+ {
38
+ k =t -2 *i ;
39
+ for (j =i ;j >=1 ;j --)
40
+ {
41
+ System .out .print ('*' );
42
+ }
43
+ l =1 ;
44
+ while (l <=k )
45
+ {
46
+ System .out .print (' ' );
47
+ l ++;
48
+ }
49
+ //System.out.print(' ');
50
+ for (j =1 ;j <=i ;j ++)
51
+ System .out .print ('*' );
52
+ System .out .println ();
53
+ }
54
+
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments