id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

zz530_1dTo2DInts


Write a function that accepts a 1-dimensional array of integers, a[], and two integers ROWS and COLS. The function copies the elements into a 2D array with the specified numbers of ROWS and COLS. Element [0] of the input array goes to element [0][0] of the 2D array. Element [1] of the input array goes to element [0][1], and so on. In the resulting 2D array, return the sum of all the elements on and below the diagonal. (The diagonal are the elements for which row == column)


zz530_1dTo2DInts([1, 2, 3, 4, 5, 6, 7, 8, 9], 3, 3) → 34
zz530_1dTo2DInts([1, 2, 3, 4, 5, 6], 2, 3) → 10
zz530_1dTo2DInts([1, 2], 1, 2) → 1

...Save, Compile, Run (ctrl-enter)

public int zz530_1dTo2DInts(int[] a, int ROWS, int COLS) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 100

Copyright Nick Parlante 2017 - privacy