title: C++ Code to Generate Permutations
body: <p>I am trying to code a program that will generate permutations with the characters repeated. So far I have 3 loops:</p>
  
  <pre><code>for (int f = 0; f &lt; n; f++)
      for (int s = 0; s &lt; n; s++)
          for (int t = 0; t &lt; n; t++)
              newString = characters[f] + characters[s] + characters[t];
  </code></pre>
  
  <p>This approach lacks generality in that it requires me to know the permutation length beforehand.</p>
  
  <p>Example: ABC</p>
  
  <pre><code>AAA AAB AAC ABA ABB ABC ACA ACB ACC 
  
  BAA BAB BAC BBA BBB BBC BCA BCB BCC
  
  CAA CAB CAC CBA CBB CBC CCA CCB CCC 
  </code></pre>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks,</p>