-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigitRhombus
More file actions
82 lines (70 loc) · 1.23 KB
/
digitRhombus
File metadata and controls
82 lines (70 loc) · 1.23 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
/*
The console has to print this:
1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1
And ask the user if he wants to continue or not.
If he wants to continue then the console has to print
again the same thing.
*/
import java.io.IOException;
public class figure
{
public static void main(String[] args) throws IOException
{
int row = 9, esp = 0, n, i;
char contin;
do
{
n = 1;
i = 1;
for(int countR = 1; countR<=row ; countR++)
{
if(countR <=5)
{
for(int countEsp =4; countEsp>= countR; countEsp--)
{
System.out.print(" ");
}
}
else
{
for(int countEsp =6; countEsp<= countR; countEsp++)
{
System.out.print(" ");
}
}
if(n!=1)
{
System.out.print(n);
}
for(int countEsp = 1 ; countEsp<= esp; countEsp++)
{
System.out.print(" ");
}
System.out.println(n);
if(countR<5)
{
esp = 2*countR-1;
n++;
}
else
{
esp = 2*(countR-i)-3;
i+=2;
n--;
}
}
System.out.print("Do you want to continue Y/N? ");
contin = (char) System.in.read();
System.in.read();
System.in.read();
}while(contin == 'y' || contin == 'Y');
}
}