ゞ沉默是金ゞ
魚離不開水,但是沒有說不離開哪滴水.
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
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
亚洲精品永久在线观看
|
久久久久亚洲AV无码麻豆
|
四虎必出精品亚洲高清
|
99爱在线精品免费观看
|
亚洲av产在线精品亚洲第一站
|
2021精品国产品免费观看
|
亚洲成年人电影网站
|
免费看h片的网站
|
亚洲综合色一区二区三区
|
最近2019中文字幕免费看最新
|
亚洲Av高清一区二区三区
|
噼里啪啦免费观看高清动漫4
|
在线精品免费视频无码的
|
亚洲AV无码专区在线电影成人
|
国产色婷婷精品免费视频
|
黄色免费在线网址
|
亚洲人色婷婷成人网站在线观看
|
中文字幕免费在线播放
|
亚洲大片在线观看
|
日韩欧美一区二区三区免费观看
|
亚洲 日韩 色 图网站
|
哒哒哒免费视频观看在线www
|
eeuss影院ss奇兵免费com
|
亚洲爆乳无码一区二区三区
|
8888四色奇米在线观看免费看
|
456亚洲人成在线播放网站
|
亚洲av日韩片在线观看
|
久久国产精品2020免费m3u8
|
亚洲人成7777
|
亚洲精品国精品久久99热
|
精品无码人妻一区二区免费蜜桃
|
亚洲欧美日韩中文无线码
|
97在线观免费视频观看
|
边摸边脱吃奶边高潮视频免费
|
久久亚洲精品中文字幕三区
|
一二三四免费观看在线视频中文版
|
国产精品亚洲精品爽爽
|
久久久久亚洲av无码尤物
|
韩国免费三片在线视频
|
国产精品99久久免费观看
|
亚洲国产精品无码久久98
|