首页 > 其他 > 详细

Leetcode566. Reshape the Matrix

时间:2017-04-30 15:53:48      阅读:450      评论:0      收藏:0      [点我收藏+]
	public int[][] func(int[][] nums,int r,int c){
		int m=nums.length;
		int k=0;
		int n=nums[0].length;
		  if(r*c!=m*n){
			return nums;
		}
		  int[][] res = new int[r][c];
		  for(int i=0;i<r;i++){
			  for(int j=0;j<c;j++,k++){
				  res[i][j]=nums[k/n][k%n];
			  }
		  }
		  return res;
		  
	}

 

Leetcode566. Reshape the Matrix

原文:http://www.cnblogs.com/vector11248/p/6789520.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!