-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjwelch_module_6.java
More file actions
45 lines (44 loc) · 1.09 KB
/
jwelch_module_6.java
File metadata and controls
45 lines (44 loc) · 1.09 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
/**
* jwelch_module_6
*/
public class jwelch_module_6 {
/**
* @param args
*/
public static void main(String[] args) {
int row;
int start;
int column = 1;
int spaces = 32;
String space= "";
String s = "";
for (row = 1; row <= 7; ++row ) {
column = row;
s = "";
start = 1;
for (column = row; column >=2; --column){
start = start *2;
}
while (start >= 1) {
s = s + " " + start;
start = (start)/2;
if (start == 0) {
break;
}
s = " " + start + s;
}
int len = s.length()/2;
spaces = (16 - len);
while (spaces >= 0) {
space = space + " ";
spaces = spaces - 1;
}
s= space + s + space;
if (len > 8){
s = s.substring(0, s.length()-1);
}
space = "";
System.out.println(s + "@");
}
}
}