ゞ沉默是金ゞ
魚離不開水,但是沒有說不離開哪滴水.
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的理解(10099)
2.?MYSQL 連接數據庫命令收藏(8621)
3.?什么是RFC?(6613)
4.?can not be represented as java.sql.Timestamp(5953)
5.?How To Avoid javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated Problem Using Apache HttpClient(3644)
評論排行榜
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
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
在线永久免费观看黄网站
|
亚洲国产日韩综合久久精品
|
在线免费观看毛片网站
|
a级毛片毛片免费观看久潮
|
精品一区二区三区免费视频
|
亚洲看片无码在线视频
|
亚洲第一区香蕉_国产a
|
亚洲午夜无码片在线观看影院猛
|
女人张开腿给人桶免费视频
|
84pao国产成视频免费播放
|
在线观看免费无码视频
|
四虎成人精品国产永久免费无码
|
中文字幕无码精品亚洲资源网久久
|
亚洲午夜精品久久久久久人妖
|
亚洲一卡2卡4卡5卡6卡在线99
|
亚洲中文久久精品无码1
|
亚洲高清专区日韩精品
|
亚洲一级片免费看
|
免费在线观看亚洲
|
国产传媒在线观看视频免费观看
|
国产在线国偷精品产拍免费
|
亚洲高清免费在线观看
|
久久99热精品免费观看牛牛
|
国产线视频精品免费观看视频
|
理论秋霞在线看免费
|
亚洲一久久久久久久久
|
99亚偷拍自图区亚洲
|
亚洲一区中文字幕在线观看
|
亚洲电影在线免费观看
|
亚洲视频在线观看不卡
|
婷婷久久久亚洲欧洲日产国码AV
|
国产精品亚洲а∨无码播放
|
国产V亚洲V天堂无码久久久
|
国产亚洲色婷婷久久99精品
|
亚洲精品无码久久一线
|
亚洲国产高清视频
|
亚洲成年人电影网站
|
亚洲国产日韩在线
|
亚洲一区二区三区国产精华液
|
在线a亚洲老鸭窝天堂av高清
|
亚洲中文精品久久久久久不卡
|