We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2b442df commit 4650fdcCopy full SHA for 4650fdc
Patterns/pat27.java
@@ -0,0 +1,38 @@
1
+class pat27 {
2
+ public static void main(String[] args) {
3
+ /*
4
+ 1 2 3 4 17 18 19 20
5
+ 5 6 7 14 15 16
6
+ 8 9 12 13
7
+ 10 11
8
+ */
9
+
10
+ int k=0,l=17;
11
12
+ for(int i=4;i>=1;i--){
13
14
+ if(i!=4) //avoid first time
15
+ l=l-(2*i);
16
17
+ for(int s=(4-i);s>=1;s--)
18
+ System.out.print(" ");
19
20
21
+ for(int j=i;j>=1;j--)
22
+ System.out.print(++k +" ");
23
24
25
+ /* triangle 2 */
26
27
28
+ for(int j=1;j<=i;j++)
29
+ System.out.print(l++ +" ");
30
31
+ l=l-1;
32
33
34
+ System.out.println();
35
+ }
36
37
38
+}
0 commit comments