java - two dimensional array sum -


I have two dimensional float array as below

  {0.2,0.0, 0.3.0.0, 0.0} {0.4,0.1,0.0,0.0,0.9} {0.0,0.0,0.0,0.3,0.6}   

I have to get the following output < Pre> {0.6,0.0,0.3,0.0,0.0} {0.6,0.1,0.0,0.0,1.5} {0.0,0.0,0.0,0.3,1.5}

if You do analysis, I give zero denominator of each column and update all non-zero values ​​with that par value. For example, in the first column I updated the value of the sum of (0.2 + 0.4 = 0.4) and the value of both with 0.6.

I am using Java, how can I do this? This is a simple example, in real time, I actually have a big array.

There is exercise for the reader in the same length in special cases.

  class matte {static void makeSums (float [] [] floats) {// We will not take any kind of action on these inputs, so come back if (floats == tap || Floats.lamm == 0 || floats.lang == 1) returns; // To make sure it is for float [] arr: Floats {if (arr.length! = Floats [0]. Length) {New illegal archive exception ("Makesm () rectangular array is required"); }} For (int i = 0; i   

and its result is:

  c: \ documents and settings \ glow \ my document & gt; Javac MatTest.java C: \ Documents and Settings \ Brightness \ My Documents & gt; Java MatTest 0.6 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.5 1.5    

Comments