-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPresentFromLena.java
More file actions
53 lines (44 loc) · 1.17 KB
/
PresentFromLena.java
File metadata and controls
53 lines (44 loc) · 1.17 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
import java.util.Scanner;
public class PresentFromLena
{
public static void main( String[] args )
{
Scanner s = new Scanner( System.in );
int n = s.nextInt();
int l = n, r = n;
for( int i = 0; i <= 2 * n; i++ )
{
int index=1;
for( int j = 0; j <= 2 * n; j++ )
{
if( j == l && (i==0 || i==2*n) )
System.out.print(0);
else if(j==l)
System.out.print(0+" ");
else if(j==r)
System.out.print( 0 );
else if(j>l && j<r)
{
System.out.print( index+" " );
if(j<n)
index++;
else
index--;
}
else if(j<n)
System.out.print( " " );
}
if( i < n )
{
l--;
r++;
}
else
{
l++;
r--;
}
System.out.println();
}
}
}