-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPattern7c.java
More file actions
30 lines (28 loc) · 742 Bytes
/
Pattern7c.java
File metadata and controls
30 lines (28 loc) · 742 Bytes
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
package com.company;
class Patternc {
public static void main(String[] args) {
int i = 1, n = 5, count = 0, count1 = 0, k = 0;
while(i <= n){
int j = 1;
while(j <= n-i){
System.out.print(" ");
count++;
j++;
}
while(k != 2*i-1){
if(count <= n-1) {
System.out.print(1+k+" ");
count++;
}
else{
count1++;
System.out.print(1+k-2*count1+" ");
}
k++;
}
count1 = count = k = 0;
i++;
System.out.println();
}
}
}