forked from ezudheen/s4OOD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathm.java
More file actions
108 lines (97 loc) · 1.71 KB
/
m.java
File metadata and controls
108 lines (97 loc) · 1.71 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import java.util.*;
class Diamond{
public static void main(String []args)
{
int n;
Scanner in=new Scanner(System.in);
n = in.nextInt();
int m=n;
for(int i=0;i<n;i++)
{
System.out.println("");
int k=2*m-1;
while(k>-(2*(n-1)))
{
System.out.print(" ");
k=k-2;
}
for(int j=(2*i+1);j>0;j--)
{
System.out.print("1");
}
m=m-1;
}
int b=n,count;
int k=n-1;
for(int i=0;i<n-1;i++)
{
System.out.println("");
while(k>0)
{
System.out.print(" ");
k--;
}
for(int x=n;x>0;x--)
{
System.out.print("1");
}
for(int c=(2*i+1);c>0;c--)
{
System.out.print(" ");
}
for(int x=n;x>0;x--)
{
System.out.print("1");
}
b=b-1;
k=b-1;
}
b=n;
k=n-1;
int d=0;
count =0;
for(int i=n-1;i>=0;i--)
{
System.out.println("");
while(d>0)
{
System.out.print(" ");
d--;
}
for(int x=0;x<n;x++)
{
System.out.print("1");
}
for(int c=(2*i+1);c>1;c--)
{
System.out.print(" ");
}
System.out.print(" ");
for(int x=n;x>0;x--)
{
System.out.print("1");
}
b=b-1;
k=b-1;
count++;
d=count;
}
m=n;
k=n;
for(int i=n-1;i>=0;i--)
{
System.out.println("");
while(k>0)
{
System.out.print(" ");
k--;
}
for(int j=(2*i+1);j>0;j--)
{
System.out.print("1");
}
m=m+1;
k=m;
}
}
}