Programming Challenge: Permutations
My question refers to the Programming Challenge section of the website wherein one of the challenges is about determining the Permutations of a string. That solution of that program has me pulling my hair. It is a recursive algorithm. For an input string "cat", once "cat" and "cta" have been printed out, the value of variable "place" turns out to be 3. At that instance, the function should terminate as the for loop does not support values equal or greater than 3. By some sort of miracle, however, the value of variable place is 1 (I put a cout statement inside the for loop). How in the world can "place" possibly be 1 after it has been 2. There is nothing that decrements place.