title: Non-repeating random numbers in vector C++
body: <p>I'm trying to store random numbers in vector, but I want each number to be unique. Can I do that with for loop without using unique() or random_shuffle() ?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;ctime&gt;
  
  using namespace std;
  
  int main()
  {
  
      srand(time(NULL));
  
      vector&lt;int&gt; v;
  
      for (unsigned int i = 0; i &lt; 30; i++) {
  
            v.push_back(rand() % 30);
      }
  
      for (unsigned int j = 0; j &lt; 30; j++) {
  
          cout &lt;&lt; v[j] &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>