title: Random array generation with no duplicates
body: <p>I am trying to create something that generates a random array with no duplicate values. I've already looked at other answers but none seem to help me understand. I cannot think of a way to actually generate random numbers that contain no duplicates. Here is what I have tried so far:</p>
  <pre class="lang-cpp prettyprint-override"><code>srand(time(NULL));
  int numbers [4];
  
  for (int x=0; x!=4;x++)
  {
      numbers[x] = 1 + (rand() % 4) ;
      printf(&quot;%d &quot;, numbers[x]);
  }
  </code></pre>