title: Fill Matrix in a special order C++
body: <p>I want to fill a 8 x 8 matrix with values in a special order (see example below), but I don´t know how to do that. Each numer stands for the ordering number: For example: #3 in the matrix is the third value of a e.g. a measurment I want to add.
  The Order should be:</p>
  
  <pre><code>1   2   5   6    17  18  21  22
  3   4   7   8    19  20  23  24
  9   10  13  14   25  26  29  30
  11  12  15  16   27  28  31  32
  
  33  34  37  38   49  50  53  54
  35  36  39  40   51  52  55  56
  41  42  45  46   57  58  61  62  
  43  44  47  48   59  60  63  64
  </code></pre>
  
  <p>Does anybody knows an algorithmus to do that? 
  I have tried this, but that´s not a good way to to it, and it´s not working for the whole matrix</p>
  
  <pre><code>int b= 0, ii = 0, a = 0, iii = 0
  
  
  i are different measurement values
  
  and now a for loop  
  
  
                      if (ii == 1)
                      {
                          b++;
  
                      }
                      if (ii == 2)
                      {
                          a++, b--;
  
                      }
                      if (ii == 3)
                      {
                          b ++;
  
                      }
                      tempMatrix[a][b] = i;
                      cout &lt;&lt; "TempMatrix " &lt;&lt; tempMatrix[a][b] &lt;&lt; "   a " &lt;&lt; a &lt;&lt; "  b " &lt;&lt; b &lt;&lt; endl;
                      if (ii == 3)
                      {
                          ii = -1;
  
                          a --;
                          b ++;
  
                      }
                      if (iii == 7)
                      {
                          a = a + 2;
                          b = 0;
                          iii = -1;
                      }
  </code></pre>