中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

政府網(wǎng)站欄目設(shè)計原則/網(wǎng)絡(luò)軟文

政府網(wǎng)站欄目設(shè)計原則,網(wǎng)絡(luò)軟文,門戶網(wǎng)站建設(shè)及運營,鞍山信息港家訊房產(chǎn)一、思路 這個題目主要有兩個問題,一是什么時候切換方向,二是如何切換方向 問題一:此步移動完后,判斷下一個元素,如果大于等于邊界值(從0開始)或者小于邊界值時或者訪問數(shù)組為真時 問題二&am…

一、思路

這個題目主要有兩個問題,一是什么時候切換方向,二是如何切換方向

問題一:此步移動完后,判斷下一個元素,如果大于等于邊界值(從0開始)或者小于邊界值時或者訪問數(shù)組為真時

問題二:創(chuàng)建一個方向數(shù)組,通過行數(shù)和列數(shù)的加減來實現(xiàn)切換方向,然后通過%4來循環(huán)訪問這個數(shù)組

二、記憶

1.二維矩陣的使用長度聲明和直接用數(shù)值定義

int[][] check = new int[rows][columns];
int[][] nextdirections ={{0,1},{1,0},{0,-1},{-1,0}};

2.方向數(shù)組來確定移動方向的思路

3.預(yù)判定的思路

int nextrow = row + nextdirections[nextdirection][0];
int nextcolumn = column + nextdirections[nextdirection][1];
if(nextcolumn>=columns || nextcolumn<0 || nextrow<0 || nextrow>=rows || check[nextrow][nextcolumn] ==1 ){nextdirection = (nextdirection+1)%4;
}

三、代碼

public List<Integer> spiralOrder(int[][] matrix){ArrayList<Integer> order = new ArrayList<>();//異常條件處理if(matrix == null || matrix.length == 0 || matrix[0].length ==0) return order;int rows = matrix.length,columns = matrix[0].length;int[][] check = new int[rows][columns];int[][] nextdirections ={{0,1},{1,0},{0,-1},{-1,0}};int total = rows*columns;int row = 0,column = 0;int nextdirection = 0;for(int i = 0;i<total;i++){order.add(matrix[row][column]);check[row][column] = 1;//預(yù)判,確定移動方向int nextrow = row + nextdirections[nextdirection][0];int nextcolumn = column + nextdirections[nextdirection][1];if(nextcolumn>=columns || nextcolumn<0 || nextrow<0 || nextrow>=rows || check[nextrow][nextcolumn] ==1 ){nextdirection = (nextdirection+1)%4;}//移動row += nextdirections[nextdirection][0];column += nextdirections[nextdirection][1];}return order;}

http://www.risenshineclean.com/news/454.html

相關(guān)文章:

  • app設(shè)計網(wǎng)站模板/google優(yōu)化師
  • 做網(wǎng)站月收入多少/百度網(wǎng)站推廣
  • 如何建立和設(shè)計公司網(wǎng)站作文/百度快速seo優(yōu)化
  • 邢臺路橋建設(shè)總公司沒有網(wǎng)站嗎/宣傳軟文范例
  • 商城網(wǎng)站建設(shè)視頻教程/關(guān)鍵詞排名優(yōu)化教程
  • 網(wǎng)站seo做哪些工作/seo引擎優(yōu)化培訓(xùn)
  • 廣州樂地網(wǎng)站建設(shè)/網(wǎng)絡(luò)營銷成功的案例及其原因
  • ppt模板制作教程步驟/360優(yōu)化大師舊版
  • 貴州省住房和城鄉(xiāng)建設(shè)管理委員會網(wǎng)站/成都seo培
  • 無錫網(wǎng)站建設(shè)企業(yè)排名/友情鏈接交易
  • wordpress 目錄改變/網(wǎng)絡(luò)優(yōu)化師
  • 福州建設(shè)委員會網(wǎng)站/福建網(wǎng)站建設(shè)制作
  • 服務(wù)器做網(wǎng)站空間/網(wǎng)店培訓(xùn)騙局
  • 網(wǎng)頁游戲網(wǎng)站建設(shè)/汕頭seo優(yōu)化項目
  • 鄭州網(wǎng)站建設(shè)哪家公司好/新品上市的營銷方案
  • 網(wǎng)站上的銷售怎么做的/百度網(wǎng)盤私人資源鏈接
  • 做網(wǎng)站掛靠服務(wù)器什么好/類聚seo
  • 百度網(wǎng)址大全導(dǎo)航首頁/九江seo公司
  • 企業(yè)網(wǎng)站模板免費版/百度一下網(wǎng)頁版瀏覽器
  • 網(wǎng)站結(jié)構(gòu)與導(dǎo)航設(shè)計/石景山區(qū)百科seo
  • 做網(wǎng)站用什么ps軟件/朋友圈營銷
  • 沭陽奧體小區(qū)做網(wǎng)站/廣州專業(yè)網(wǎng)絡(luò)推廣公司
  • 申報城市維護建設(shè)稅上哪個網(wǎng)站/網(wǎng)站運營工作內(nèi)容
  • 武義網(wǎng)站建設(shè)/互聯(lián)網(wǎng)營銷師培訓(xùn)機構(gòu)
  • 公益網(wǎng)站建設(shè)需求/大數(shù)據(jù)分析師
  • 沈陽網(wǎng)站建設(shè)建設(shè)公司/怎么創(chuàng)建網(wǎng)站平臺
  • 霸州放心的網(wǎng)絡(luò)建站/愛戰(zhàn)網(wǎng)關(guān)鍵詞查詢網(wǎng)站
  • 寧波免費網(wǎng)頁制作模板/曹操博客seo
  • app store官方正版下載/班級優(yōu)化大師簡介
  • 怎么防止網(wǎng)站被鏡像/nba賽季排名