-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern.java
More file actions
84 lines (73 loc) · 1.9 KB
/
Copy pathpattern.java
File metadata and controls
84 lines (73 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
public class pattern{
public static void p1(int n){
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++){
System.out.print(i + " ");
}
System.out.println();
}
}
public static void p2(int n){
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++){
System.out.print(j + " ");
}
System.out.println();
}
}
public static void p3(int n){
for(int i=1; i<=n; i++){
for(int j=1; j<=n-i+1; j++){
System.out.print(i + " ");
}
System.out.println();
}
}
public static void p4(int n){
for(int i=1; i<=n; i++){
for(int j=1; j<=n-i+1; j++){
System.out.print(j + " ");
}
System.out.println();
}
}
public static void floyds(int n){
int count = 1;
for(int i=1; i<=n ; i++){
for(int j=1; j<=i; j++){
System.out.print(count + " ");
count++;
}
System.out.println();
}
}
public static void p5(int n){
int count = 1;
for(int i=1; i<=n ; i++){
for(int j=1; j<=n-i+1; j++){
System.out.print(count + " ");
count++;
}
System.out.println();
}
}
public static void p6(int n){
int count = 15;
for(int i=1; i<=n ; i++){
for(int j=1; j<=i; j++){
System.out.print(count + " ");
count --;
}
System.out.println();
}
}
public static void main(String args[]){
// p1(5);
// p2(5);
//p3(5);
//p4(5);
// floyds(5);
// p5(5);
p6(5);
}
}