vector<int> clockwisePrint(vector<vector<int> > mat, int n, int m) { vector<int> ret; int i=0; int j=0; int startx=0; int starty=0; int endx=n-1; int endy=m-1; while(startx<=endx && starty<=endy){ if(endy==starty){ for(j=endy,i=startx;i<=endx;++i){ ret.push_back(mat[i][j]); } return ret; } if(endx==startx){ for(i=startx,j=starty;j<=endy;++j){ ret.push_back(mat[i][j]); } return ret; } for(i=startx,j=starty;j<=endy;++j){ ret.push_back(mat[i][j]); } for(j=endy,i=startx+1;i<=endx;++i){ ret.push_back(mat[i][j]); } for(i=endx,j=endy-1;j>=starty;--j){ ret.push_back(mat[i][j]); } for(j=starty,i=endx-1;i>startx;--i){ ret.push_back(mat[i][j]); } startx++; starty++; endx--; endy--; } return ret; }
分享名稱:順時(shí)針打印矩陣
文章分享:http://chinadenli.net/article0/gissio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、、關(guān)鍵詞優(yōu)化、全網(wǎng)營(yíng)銷(xiāo)推廣、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)