ゞ沉默是金ゞ
魚離不開水,但是沒有說不離開哪滴水.
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
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
毛片免费观看视频
|
国产男女爽爽爽爽爽免费视频
|
成全影视免费观看大全二
|
亚洲系列中文字幕
|
亚洲国产精品免费在线观看
|
亚洲情a成黄在线观看动漫尤物
|
97在线视频免费播放
|
亚洲午夜免费视频
|
91精品免费国产高清在线
|
亚洲一区二区三区免费视频
|
免费在线观看h片
|
性xxxx黑人与亚洲
|
成人免费无码大片a毛片软件
|
亚洲欧美成人一区二区三区
|
日韩特黄特色大片免费视频
|
野花视频在线官网免费1
|
国内精品久久久久久久亚洲
|
久久黄色免费网站
|
亚洲熟妇av一区
|
国产男女猛烈无遮挡免费视频
|
蜜芽亚洲av无码精品色午夜
|
日韩插啊免费视频在线观看
|
亚洲一卡2卡3卡4卡国产网站
|
成全视频在线观看免费高清动漫视频下载
|
2020年亚洲天天爽天天噜
|
日韩一区二区在线免费观看
|
日本视频免费观看
|
亚洲AV日韩AV永久无码久久
|
成人免费视频77777
|
色婷婷综合缴情综免费观看
|
亚洲AV无码乱码国产麻豆
|
久久久高清免费视频
|
国产精品久久亚洲一区二区
|
亚洲午夜久久久久妓女影院
|
国产国产人免费视频成69堂
|
爱情岛亚洲论坛在线观看
|
少妇中文字幕乱码亚洲影视
|
免费夜色污私人影院在线观看
|
最近中文字幕大全免费版在线
|
色在线亚洲视频www
|
亚洲精品无码专区久久久
|