蝦米爬啊爬
-xiami's blog
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(4)
給我留言
查看公開留言
查看私人留言
隨筆檔案
(16)
2007年7月 (1)
2007年5月 (1)
2007年4月 (1)
2007年3月 (2)
2006年11月 (11)
相冊
xiami's photo
最新隨筆
1.?where 1=1(摘)
2.?String 轉 Date
3.?命名規則
4.?ajax(百度百科)
5.?名詞解釋(來源于百度百科)
6.?使用netbeans開發一個javabean程序
7.?建立一個螺旋形矩陣A[n][n]
8.?servlet-api的基本類和其接口介紹
9.?使用netbeans啟動捆綁tomcat出現某工程目錄does not exist or is not a readable directory
10.?JAVA連接MYSQL
11.?管道流通信
12.?用File類來列出和篩選所有文件
13.?java.util下的Class Collections的兩種sort方法使用
14.?靜態內部類
15.?1.5容器note問題
積分與排名
積分 - 18015
排名 - 1851
最新評論
1.?re: 使用netbeans啟動捆綁tomcat出現某工程目錄does not exist or is not a readable directory
評論內容較長,點擊標題查看
--rel
2.?re: 使用netbeans啟動捆綁tomcat出現某工程目錄does not exist or is not a readable directory
多半是只讀,改下子文件屬性,把只讀去掉
--老左zuoge85@gmail.com
3.?re: 使用netbeans啟動捆綁tomcat出現某工程目錄does not exist or is not a readable directory
看看你們那個文件目錄是不是只讀的
--老左zuoge85@gmail.com
4.?re: servlet-api的基本類和其接口介紹
東西很多但是很抽象,迷糊中...
--sophia
5.?re: 使用netbeans啟動捆綁tomcat出現某工程目錄does not exist or is not a readable directory
謝謝謝謝 我也這樣 終于找到答案了
--amber
閱讀排行榜
1.?使用netbeans啟動捆綁tomcat出現某工程目錄does not exist or is not a readable directory(5502)
2.?String 轉 Date(2689)
3.?java.util下的Class Collections的兩種sort方法使用(2181)
4.?使用netbeans開發一個javabean程序(1959)
5.?使用commons-fileupload包進行文件上傳(1003)
評論排行榜
1.?使用netbeans啟動捆綁tomcat出現某工程目錄does not exist or is not a readable directory(4)
2.?servlet-api的基本類和其接口介紹(1)
3.?where 1=1(摘)(0)
4.?String 轉 Date(0)
5.?命名規則(0)
Powered by:
博客園
模板提供:
滬江博客
BlogJava
|
首頁
|
發新隨筆
|
發新文章
|
聯系
|
聚合
|
管理
建立一個螺旋形矩陣A[n][n]
任給一個整數n,建立一個螺旋形矩陣A[n][n]。
1??? 2??? 3??? 4?? 5
16? 17?? 18??? 19? 6
15? 24?? 25??? 20? 7
14?? 23? 22??? 21? 8
13?? 12? 11??? 10? 9
public
?
class
?Main?
{
????
public
?
static
?
void
?main(String[]?args)?
{
????????
//
?TODO?Auto-generated?method?stub
????????
int
?n
=
5
;
????????
int
?[][]table
=
new
?
int
?[n
+
2
][n
+
2
];
????????
//
初始化
????????
int
?i,j;
????????
for
(i
=
0
;i
<=
n
+
1
;i
++
)?
{
????????????
for
(j
=
0
;j
<=
n
+
1
;j
++
)
????????????????table[i][j]
=-
1
;
????????}
????????
for
(i
=
1
;i
<=
n;i
++
)?
{
????????????
for
(j
=
1
;j
<=
n;j
++
)
????????????????table[i][j]
=
0
;
????????}
????????
//
創建
????????
????????
int
?row
=
1
;
int
?column
=
1
;
int
?k;
???????
//
?table[1][1]=1;
????????
int
?dire
=
0
;
//
0右,1下,2左,3上
????????
for
(k
=
1
;k
<=
n
*
n;)?
{
????????????
if
(dire
==
0
)?
{
//
方向為右
????????????????table[row][column]
=
k
++
;
????????????????
if
(table[row][column
+
1
]
==
0
)
{
????????????????????column
++
;
????????????????}
else
{
????????????????????dire
=
1
;
//
改方向為下
????????????????????row
++
;
????????????????}
????????????????
continue
;
????????????}
????????????
if
(dire
==
1
)?
{
//
方向為下
????????????????table[row][column]
=
k
++
;
????????????????
if
(table[row
+
1
][column]
==
0
)
{
????????????????????row
++
;
????????????????}
else
{
????????????????????dire
=
2
;
//
改方向為左
????????????????????column
--
;
????????????????}
?????????????????
continue
;
????????????}
????????????
if
(dire
==
2
)?
{
//
方向為左
????????????????table[row][column]
=
k
++
;
????????????????
if
(table[row][column
-
1
]
==
0
)
{
????????????????????column
--
;
????????????????}
else
{
????????????????????dire
=
3
;
//
改方向為右
????????????????????row
--
;
????????????????}
?????????????????
continue
;
????????????}
????????????
if
(dire
==
3
)?
{
//
方向為上
????????????????table[row][column]
=
k
++
;
????????????????
if
(table[row
-
1
][column]
==
0
)
{
????????????????????row
--
;
????????????????}
else
{
????????????????????dire
=
0
;
//
改方向為右
????????????????????column
++
;
????????????????}
?????????????????
continue
;
????????????}
????????}
????????
????????
//
輸出
????????
for
(row
=
1
;row
<=
n;row
++
)?
{
????????????
for
(column
=
1
;column
<=
n;column
++
)
????????????????System.out.print(table[row][column]
+
"
????
"
);
????????????System.out.println();}
????????
????}
}
當然,這個程序還有很多可以優化的地方。在此就不多說了。
發表于 2006-11-29 17:26
蝦米
閱讀(435)
評論(0)
編輯
收藏
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
主站蜘蛛池模板:
久久免费看黄a级毛片
|
男女午夜24式免费视频
|
AV免费网址在线观看
|
亚洲人成网www
|
黄色免费在线网站
|
亚洲av无码成h人动漫无遮挡
|
久久久WWW免费人成精品
|
国内精品久久久久久久亚洲
|
www.xxxx.com日本免费
|
亚洲日韩中文字幕日韩在线
|
乱淫片免费影院观看
|
久久久久久亚洲精品不卡
|
中文在线观看永久免费
|
亚洲av中文无码乱人伦在线r▽
|
四虎国产精品永久免费网址
|
久久精品国产亚洲AV香蕉
|
最近中文字幕免费2019
|
亚洲精品国产电影午夜
|
日韩视频在线精品视频免费观看
|
亚洲精品国产日韩
|
国产精品色午夜视频免费看
|
免费一级做a爰片久久毛片潮
|
亚洲最大AV网站在线观看
|
免费无码一区二区三区
|
亚洲一级毛片免观看
|
国产成人aaa在线视频免费观看
|
乱人伦中文视频在线观看免费
|
国产成A人亚洲精V品无码性色
|
99国产精品免费观看视频
|
亚洲偷偷自拍高清
|
亚洲国产一级在线观看
|
免费观看在线禁片
|
亚洲人成未满十八禁网站
|
亚洲日本中文字幕天堂网
|
久久久久久久99精品免费
|
亚洲成在人线aⅴ免费毛片
|
亚洲AV无码成H人在线观看
|
国产一区二区三区免费
|
亚洲欧洲日产国码久在线
|
亚洲中文久久精品无码ww16
|
美女内射毛片在线看免费人动物
|