title: All permutations c++ with vector<int> and backtracking
body: <p>I'm trying generate all permutations of an vector to training backtracking technique but my code don't work for all vectors (works to size to vectors)</p>
  
  <p>my code :</p>
  
  <pre><code>#include &lt;bits/stdc++.h&gt;
  
  using namespace std;
  
  void permutations(int s,vector&lt;int&gt; v){
      if(s&gt;=v.size())
          return;
      if( v.size()==0)
          cout&lt;&lt;endl;
      cout&lt;&lt;v[s]&lt;&lt;" ";
      vector&lt;int&gt; k = v;
  
      k.erase(k.begin()+s);
  
      for(int i =0;i&lt;k.size();i++)
          return permutations(i,k);
  
  }
  
  int main(int argc, char const *argv[])
  {
      vector&lt;int&gt; v = {1,2,3};
      for(int i =0;i&lt;v.size();i++){
          permutations(i,v);
          cout&lt;&lt;endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I think is because when my recursive function find return they break the for but maybe I 'm wrong someone can tell my what's the problem and how can I correct it please. </p>