forked from Apurv0007/enjoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p4.java
38 lines (38 loc) · 994 Bytes
/
p4.java
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
import java.util.Scanner;
public class p4{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
int n=sc.nextInt();
int sp = n / 2, st = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= sp; j++)
System.out.print(" ");
int count = st / 2 + 1;
for (int k = 1; k <= st; k++) {
System.out.print(count);
if (k <= st / 2)
count--;
else
count++;
}
System.out.println();
if (i <= n / 2) {
sp = sp - 1;
st = st + 2;
}
else {
sp = sp + 1;
st = st - 2;
}
}
}
}
//.........
// updated
//HR
//$
//............
//.....
//......
//// updated........