title: How to print specific amount of elements of array per line?
body: <p>I want to print 10 elements per line of the array, so output would look something like this:</p>
  
  <pre><code> 1  2  3  4  5  6  7  8  9 10
  11 12 13 14 15 16 17 18 19 20
  ...etc
  </code></pre>
  
  <p>And here's my code so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ctime&gt;
  #include &lt;cstdlib&gt;
  #include &lt;algorithm&gt;
  
  using namespace std;
  
  int main()
  {
      srand(time(0));
      int array[1000];
      for (int i = 0; i &lt; 1000; i++) array[i] = rand() % 1000;
      sort(array, array + 1000);
      for (int i = 0; i &lt; 1000;){
          i += 10;
          for(int j = 0; j &lt; i; j++){
              cout &lt;&lt; array[j] &lt;&lt; " ";
          }
          cout &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>But I can't get it to work. For some reason it repeats all the numbers over and over.</p>