shuffle a 3d array in c++
<p>I have this piece of code which creates a 3d array and places 1-9 in a 3x3x3 box. I need to find a way to shuffle the elements of this array to compare how closely the newly shuffled array is to a magic square. Any ideas are appreciated! Thanks!</p>

<pre><code> for(i = 0; i &lt; x; i++)
{
    cout &lt;&lt; "Finding a Magic Square..." &lt;&lt; endl;

    for(j = 0; j &lt; y; j++)
    {
        cout &lt;&lt; endl;

        for(k = 0; k &lt; z; k++)
        {
            array3D[i][j][k] = (i+1) + (j * z) + k;
            cout &lt;&lt; '\t' &lt;&lt; array3D[i][j][k];
        }
    }

    cout &lt;&lt; endl &lt;&lt; endl;
}
</code></pre>
