title: C++ <algorithm> permutation
body: <p>Why is this code note working (the code compiles and run fine, but is not actually showing the permutations):</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      long number;
      vector&lt;long&gt; interval;
      vector&lt;long&gt;::const_iterator it;
  
      cout &lt;&lt; "Enter number: ";
      cin &gt;&gt; number;
  
      while(number--&gt;0){
          interval.push_back(number);
      }
  
      do{
          for(it = interval.begin(); it &lt; interval.end(); ++it){
              cout &lt;&lt; *it &lt;&lt; " ";
          }
          cout &lt;&lt; endl;
      } while(next_permutation(interval.begin(), interval.end()));
  
      return (0);
  }
  </code></pre>
  
  <p>But after changing this line:</p>
  
  <pre><code>while(next_permutation(interval.begin(), interval.end()));
  </code></pre>
  
  <p>with:</p>
  
  <pre><code>while(prev_permutation(interval.begin(), interval.end()));
  </code></pre>
  
  <p>Isn't permutation changing the elements in the vector by acting on positions ?</p>
  
  <p><strong>PS:
  I've edited the code now.</strong></p>