ゞ沉默是金ゞ
魚離不開水,但是沒有說不離開哪滴水.
BlogJava
首頁
新隨筆
新文章
聯系
聚合
管理
posts - 98,comments - 104,trackbacks - 0
<
2009年6月
>
日
一
二
三
四
五
六
31
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
1
2
3
4
5
6
7
8
9
10
11
常用鏈接
我的隨筆
我的文章
我的評論
我的參與
最新評論
留言簿
(3)
給我留言
查看公開留言
查看私人留言
隨筆分類
Ant
Broker(1)
DB(8)
EJB(2)
eXtreme(7)
Hibernate
HTTP(6)
Java EE(8)
Java SE(31)
Jrules
Maven
Spring
Spring基礎(1)
Struts
webservice(2)
其他收集(6)
性能測試(1)
搜索引擎
面試相關
隨筆檔案
2012年12月 (1)
2012年11月 (1)
2012年8月 (16)
2012年7月 (6)
2012年6月 (11)
2011年3月 (1)
2010年12月 (1)
2010年11月 (2)
2010年8月 (1)
2010年7月 (3)
2010年5月 (1)
2010年1月 (1)
2009年12月 (3)
2009年11月 (2)
2009年8月 (1)
2009年6月 (4)
2009年5月 (1)
2009年4月 (1)
2009年3月 (6)
2009年2月 (3)
2008年12月 (4)
文章分類
EJB(1)
代碼收集
實用腳本
文章檔案
2012年6月 (2)
2012年1月 (1)
2011年8月 (1)
2009年11月 (1)
2009年3月 (1)
2009年2月 (2)
搜索
最新評論
1.?re: How to Create Client/Server Keystores using Java Keytool
Shawn?
--Freud
2.?re: HTTP/1.1 Cache-Control的理解
這是網頁代碼,還是IIS 代碼
--marmoglass
3.?re: How To Avoid javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated Problem Using Apache HttpClient
評論內容較長,點擊標題查看
--dashi99
4.?re: How To Avoid javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated Problem Using Apache HttpClient
評論內容較長,點擊標題查看
--shigangxing
5.?re: Part 12: java.util.concurrent : SingleThreadPool Example
評論內容較長,點擊標題查看
--NotNolyJava
閱讀排行榜
1.?HTTP/1.1 Cache-Control的理解(10097)
2.?MYSQL 連接數據庫命令收藏(8620)
3.?什么是RFC?(6612)
4.?can not be represented as java.sql.Timestamp(5949)
5.?How To Avoid javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated Problem Using Apache HttpClient(3640)
評論排行榜
1.?Java應用基礎:網友精選25個Java試題分享(18)
2.?踏實與成功(11)
3.?Eclipse中10個比較有用的快捷鍵組合(轉)(7)
4.?摘:一個Java程序員應該掌握的10項技能(6)
5.?Java獲取客戶端真實IP地址的兩種方法(5)
用 * 打印出各種圖形
先看效果:
代碼:
public
class
PrintTriangle
{
public
static
void
main(String[] args)
{
System.out.println(
"
======左邊正三角形======
"
);
printTopLeft(
5
);
System.out.println(
"
======左邊倒三角形======
"
);
printDownLeft(
5
);
System.out.println(
"
======打印右正三角形======
"
);
printTopRight(
5
);
System.out.println(
"
======打印右倒三角形======
"
);
printDownRight(
5
);
System.out.println(
"
======打印正中三角形======
"
);
printTopCenter(
5
);
System.out.println(
"
======打印倒中三角形======
"
);
printDownCenter(
5
);
System.out.println(
"
======打印中正空三角形======
"
);
printTopMidBlank(
5
);
System.out.println(
"
======打印中倒空三角形======
"
);
printDownMidBlank(
5
);
System.out.println(
"
======打印正人字狀======
"
);
printTopRen(
5
);
}
/**/
/*
* 打印正人字狀
*/
public
static
void
printTopRen(
int
n)
{
for
(
int
i
=
1
; i
<=
n; i
++
)
{
for
(
int
j
=
i; j
<
n; j
++
)
{
System.out.print(
"
"
);
}
//
左半部分
for
(
int
j
=
1
; j
<=
i; j
++
)
{
if
(j
==
1
)
System.out.print(
"
*
"
);
else
System.out.print(
"
"
);
}
//
右半部分
for
(
int
j
=
1
; j
<
i; j
++
)
{
if
(j
==
i
-
1
)
System.out.print(
"
*
"
);
else
System.out.print(
"
"
);
}
System.out.println();
}
}
/**/
/*
* 打印倒空三角形
*/
public
static
void
printDownMidBlank(
int
n)
{
for
(
int
i
=
1
; i
<=
n; i
++
)
{
for
(
int
j
=
1
; j
<
i; j
++
)
{
System.out.print(
"
"
);
}
for
(
int
j
=
i; j
<=
n; j
++
)
{
if
(i
==
1
||
j
==
i
||
i
==
n)
System.out.print(
"
*
"
);
else
System.out.print(
"
"
);
}
for
(
int
j
=
i; j
<
n; j
++
)
{
if
(i
==
1
||
j
==
n
-
1
)
System.out.print(
"
*
"
);
else
System.out.print(
"
"
);
}
System.out.println();
}
}
/**/
/*
* 打印中正空三角形
*/
public
static
void
printTopMidBlank(
int
n)
{
for
(
int
i
=
1
; i
<=
n; i
++
)
{
for
(
int
j
=
i; j
<
n; j
++
)
{
System.out.print(
"
"
);
}
//
左半部分
for
(
int
j
=
1
; j
<=
i; j
++
)
{
if
(j
==
1
||
i
==
n)
System.out.print(
"
*
"
);
else
System.out.print(
"
"
);
}
//
右半部分
for
(
int
j
=
1
; j
<
i; j
++
)
{
if
(j
==
i
-
1
||
i
==
n)
System.out.print(
"
*
"
);
else
System.out.print(
"
"
);
}
System.out.println();
}
}
/**/
/*
* 打印倒中三角形
*/
public
static
void
printDownCenter(
int
n)
{
for
(
int
i
=
1
; i
<=
n; i
++
)
{
for
(
int
j
=
1
; j
<
i; j
++
)
{
System.out.print(
"
"
);
}
for
(
int
j
=
i; j
<=
n; j
++
)
{
System.out.print(
"
*
"
);
}
for
(
int
j
=
i; j
<
n; j
++
)
{
System.out.print(
"
*
"
);
}
System.out.println();
}
}
/**/
/*
* 打印正中三角形
*/
public
static
void
printTopCenter(
int
n)
{
for
(
int
i
=
1
; i
<=
n; i
++
)
{
for
(
int
j
=
i; j
<
n; j
++
)
{
System.out.print(
"
"
);
}
//
左半部分
for
(
int
j
=
1
; j
<=
i; j
++
)
{
System.out.print(
"
*
"
);
}
//
右半部分
for
(
int
j
=
1
; j
<
i; j
++
)
{
System.out.print(
"
*
"
);
}
System.out.println();
}
}
/**/
/*
* 打印右倒三角形
*/
public
static
void
printDownRight(
int
n)
{
for
(
int
i
=
n; i
>=
1
; i
--
)
{
for
(
int
j
=
n; j
>
i; j
--
)
{
System.out.print(
"
"
);
}
for
(
int
j
=
i; j
>=
1
; j
--
)
{
System.out.print(
"
*
"
);
}
System.out.println();
}
}
/**/
/*
* 打印右正三角形
*/
public
static
void
printTopRight(
int
n)
{
for
(
int
i
=
1
; i
<=
n; i
++
)
{
for
(
int
j
=
n; j
>
i; j
--
)
{
System.out.print(
"
"
);
}
for
(
int
j
=
i; j
>=
1
; j
--
)
{
System.out.print(
"
*
"
);
}
System.out.println();
}
}
/**/
/*
* 打印左正三角型
*/
public
static
void
printTopLeft(
int
n)
{
for
(
int
i
=
1
; i
<=
n; i
++
)
{
for
(
int
j
=
1
; j
<=
i; j
++
)
{
System.out.print(
"
*
"
);
}
System.out.println();
}
}
/**/
/*
* 打印左倒三角形
*/
public
static
void
printDownLeft(
int
n)
{
for
(
int
i
=
1
; i
<=
n; i
++
)
{
for
(
int
j
=
n; j
>=
i; j
--
)
{
System.out.print(
"
*
"
);
}
System.out.println();
}
}
}
希望大家多提意見。
posted on 2009-06-02 14:43
ゞ沉默是金ゞ
閱讀(1405)
評論(2)
編輯
收藏
所屬分類:
Java SE
FeedBack:
#
re: 用 * 打印出各種圖形
2009-06-02 15:03 |
FEJAY
學習了
回復
更多評論
#
re: 用 * 打印出各種圖形
2009-06-03 17:14 |
thebye85
看得我都是星星
回復
更多評論
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
jvm學習筆記
ThreadPoolExecutor usage summary
Part 13: java.util.concurrent - Atomic Variables
Part 12: java.util.concurrent : SingleThreadPool Example
Part 11: java.util.concurrent - CachedThreadPool Example
Part 10: java.util.concurrent - ScheduledThreadPool Example
Part 9: java.util.concurrent : FixedThreadPool Example
Part 8: java.util.concurrent - "Executors" Factory Threads Pool
Part 7: java.util.concurrent - invokeAll via ExecutorService
Part 6: java.util.concurrent - Lock and Condition Object
Copyright ©2025 ゞ沉默是金ゞ Powered By
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
亚洲欧洲久久精品
|
边摸边吃奶边做爽免费视频网站
|
一二三四在线播放免费观看中文版视频
|
在线观看国产区亚洲一区成人
|
国产免费一区二区视频
|
亚洲毛片无码专区亚洲乱
|
国产成人精品免费视频软件
|
一区二区免费电影
|
亚洲国产成AV人天堂无码
|
亚洲AV成人潮喷综合网
|
57pao国产成视频免费播放
|
亚洲欧美在线x视频
|
久久精品亚洲一区二区
|
亚洲情a成黄在线观看动漫尤物
|
好爽…又高潮了免费毛片
|
国产一二三四区乱码免费
|
激情内射亚洲一区二区三区爱妻
|
亚洲一区二区精品视频
|
亚洲三级高清免费
|
黄视频在线观看免费
|
亚洲午夜无码毛片av久久京东热
|
亚洲精品无码不卡在线播放HE
|
成年午夜视频免费观看视频
|
a级毛片视频免费观看
|
亚洲AV无码一区二区三区鸳鸯影院
|
亚洲AV成人精品网站在线播放
|
日本一区免费电影
|
日本免费人成在线网站
|
成在人线av无码免费高潮水
|
在线观看亚洲AV日韩AV
|
亚洲AV成人一区二区三区AV
|
亚洲国产成人精品女人久久久
|
日韩在线视频线视频免费网站
|
亚洲一区二区三区播放在线
|
亚洲色爱图小说专区
|
免费国产不卡午夜福在线
|
色婷婷7777免费视频在线观看
|
精品一卡2卡三卡4卡免费视频
|
精品特级一级毛片免费观看
|
国产午夜亚洲精品国产
|
亚洲福利一区二区三区
|