title: Permutations & combination generating algorithm
body: <p>I m suppose to write down an algorithm for printing out all possible combinations of given pairs of ‘&lt;>’, I have tried to developed an algorithm to work this out but I think that’s not correct, because I do realize this problem is related to permutations [nPr] &amp; let’s say for a given input of 5 it should create 120 combinations (5P5=120) but my code is only generating 81.</p>
  
  <p><code>In my code have tried to generate all possible combinations by placing every element at every place one by one, but now I am little confused about how correct this approach is?</code></p>
  
  <p>Thing is Most likely am not able to grasp the real concept of 'making subsets/combinations/permutations' (though theoretically I know what they are and how to calculate them)</p>
  
  <p>I am not looking for a complete final "spoon feeded code", but something that could explain me ‘what I should be doing’, from which I could extract out the steps, understand concept and can develop my own.</p>
  
  <p><code>If possible something extending or tweaking my current coding to achieve the right result would be easier for me to understand.</code></p>
  
  <pre><code>void permute()
  {
      string str=”&lt;&gt;&lt;&gt;&lt;&gt;”;
      char buck=' ';
  for(int a=0;a&lt;str.length()-1;a++)
      {
          for(int b=0;b&lt;str.length()-1;b++){
              cout&lt;&lt;str&lt;&lt;endl;
              buck=str[b];
              str[b]=str[b+1];
              str[b+1]=buck;
          }
      }
  }
  </code></pre>
  
  <p>I have been trying to understand what I should do but i'am still struggling, any help or guidance would be really helpful.
  Thankyou</p>
  
  <hr>
  
  <p><code>From 'all combinations' i mean printing out all the possible ways given set of characters can be arranged, lets say for 2 pairs '&lt;&gt;&lt;&gt;' it should be like: &lt;&gt;&lt;&gt;,&gt;&lt;&lt;&gt;,&gt;&lt;&lt;&gt;,&gt;&lt;&gt;&lt;,&lt;&lt;&gt;&gt;,&gt;&gt;&lt;&lt; ... ... ...</code></p>