title: How do I add the value -1 in front of odd numbered elements in a C++ vector, I have problems using the insert function
body: <pre><code>int main ()
  {
      vector &lt; int  &gt; v;
      v = initialize (v);
      cout &lt;&lt; "Initial Vector: " &lt;&lt; endl;
      print (v);
      cout &lt;&lt; "Adding -1 in front of Odds: " &lt;&lt; endl;
      v = insert_odds(v);
      cout &lt;&lt; "Final Vector: " &lt;&lt; endl;
      print(v);
  }
  
  double random (unsigned int &amp;seed)
  {
      const int MODULUS = 15749;
      const int MULTIPLIER = 69069;
      const int INCREMENT = 1;
      seed = ((MULTIPLIER * seed) + INCREMENT) % MODULUS;
      return double (seed) / double (MODULUS);
  }
  
  vector &lt;int &gt; initialize (vector &lt; int &gt; v)
  {
      unsigned int seed=2;
      for (int i = 0; i &lt; 10; i++)
          v.push_back(int (10 + (10 * random (seed))));
      return v;
  }
  
  void print (vector &lt; int &gt; v)
  {
  
      for (int i = 0; i &lt; v.size(); i++)
          cout &lt;&lt; v[i] &lt;&lt; " ";
      cout &lt;&lt; endl;
  }
  bool isOdd(int n)
  {
      return n%2 != 0 &amp;&amp; n &gt; 0;
  }
  
  vector&lt;int&gt; insert_odds(vector &lt;int&gt; v)
  {
      std::vector&lt;int&gt;::iterator it = find_if(v.begin(),v.end(),isOdd);
      while(it  != v.end())
      {
           it = find_if(v.begin(),v.end(),isOdd);
           v.insert(it,-1);
      }
      return v;
  }
  </code></pre>
  
  <p>This is the code I have.
  The vector at the beginning is 
  17 10 14 16 15 19 19 10 14 18
  and I want the output to be
  -1 17 10 14 16 -1 15 -1 19 -1 19 10 14 18</p>
  
  <p>As of right now the program runs but doesn't have an output.</p>