Climbing的专栏
Life is limited, but art is long
登录
注册
全站
当前博客
空间
博客
好友
相册
留言
huang Climbing
ID:hpdlzu80100
共
3116
次访问,排名
2万外
好友
4
人,关注者
7
人
热爱生活,积极向上,流自己的汗,吃自己的饭!
hpdlzu80100的文章
原创 23 篇
翻译 0 篇
转载 5 篇
评论 1 篇
最近评论
diqizhan:
很喜欢这个
文章分类
IT Industry and Career
(RSS)
Java Learning
(RSS)
Software Testing
(RSS)
Temp
(RSS)
收藏
相册
存档
2008年05月(4)
2008年04月(24)
软件项目交易
订阅我的博客
大小可变钻石形状(Display a diamond shape constituted by asterisks)
收藏
新一篇: 摄氏温度和华氏温度的互换(Convert between Celsius and Fahrenheit temperature)
|
旧一篇: 勾股数列表(Find Pythagorean Triples)
//
Display a diamond shape constituted by asterisks
//
Java how to program, 5/e, Exercises 5.20, 5.21
import
javax.swing.
*
;
public
class
AsteriskDiamond
...
{
public
static
void
main(String arg[])
...
{
int
size;
String Size;
boolean
guard;
Size
=
JOptionPane.showInputDialog(
"
Enter the diamond size:
"
);
size
=
Integer.parseInt(Size);
if
(size
%
2
==
0
||
size
<
1
)
JOptionPane.showMessageDialog(
null
,
"
Please enter a nonegative odd number
"
,
"
Diamond Display
"
,JOptionPane.ERROR_MESSAGE);
else
...
{
for
(
int
i
=
1
;i
<=
size;i
++
)
...
{
for
(
int
j
=
1
;j
<=
size;j
++
)
...
{
if
(i
<=
size
/
2
+
1
)
guard
=
(size
/
2
+
1
-
j
<
i
&&
size
/
2
+
1
-
j
>=
0
)
||
(j
-
size
/
2
-
1
<
i
&&
j
-
size
/
2
-
1
>=
0
);
else
guard
=
(size
/
2
+
1
-
j
<=
size
-
i
&&
size
/
2
+
1
-
j
>=
0
)
||
(j
-
size
/
2
-
1
<=
size
-
i
&&
j
-
size
/
2
-
1
>=
0
);
if
(guard)
System.out.print(
"
*
"
);
else
System.out.print(
"
"
);}
System.out.print(
"
"
);
}
}
}
}
发表于 @
2008年04月09日 11:25:00
|
评论(
loading...
)
|
编辑
新一篇: 摄氏温度和华氏温度的互换(Convert between Celsius and Fahrenheit temperature)
|
旧一篇: 勾股数列表(Find Pythagorean Triples)
评论:没有评论。
发表评论
姓 名:
主 页:
校验码:
看不清,换一张
登录