Covert 2D array to 1D array storing the 2D array position (col, row) and the value in a 1D array
<p>I have managed to convert it to output the values from the 2D array, but have no idea how to get the position.</p>

<p>Here is my code:</p>

<pre><code>public static int[] convert(int [][]twodarray)
{
    int[] onedarray = new int[twodarray.length * twodarray.length];
    for(int i = 0; i &lt; twodarray.length; i ++)
    {
        for(int s = 0; s &lt; twodarray.length; s ++)
        {
            onedarray[(i * twodarray.length) + s] = twodarray[i][s];
        }
    }
    return onedarray;
}

public static int [] printonedarray(int [] onedarray)
{
    System.out.print("onedarray: ");

    for(int i = 0; i &lt; onedarray.length; i++) 
    {

            System.out.print(onedarray[i] + "\t");

    }
    System.out.println();
    return onedarray;
}
</code></pre>
