announcements‎ > ‎

2015-11-18 HW

posted Nov 18, 2015, 1:05 PM by Samuel Konstantinovich   [ updated Nov 18, 2015, 7:47 PM ]

Write a function:


public static int[][] convert ( int [] data , int rows, int cols){  }

//Precondition: data.length == rows * cols


Sample:

convert (  {3,4,5,6,7,8,9,0,6,3,4,5},3,4) 

//it will return a 2d array as follows:

{ {3,4,5,6} , 

  {7,8,9,0}, 

  {6,3,4,5} }  // 3 rows means 3 arrays. 4 cols means 4 elements each. 

Comments