Here is the permutation generator in c++:

#include<iostream>
using namespace std;
int count;
void perm(string str,int n)
{
    if(n>=str.length()) {cout<<"("<<++count<<") "<<str<<endl;return;}
    for(int i=n;i<str.length();i++)
    {
        char temp;
        temp=str.at(i); str.at(i)=str.at(n); str.at(n)=temp;
        perm(str,n+1);
        temp=str.at(i); str.at(i)=str.at(n); str.at(n)=temp;
    }
}
int main()
{
    string str;
    cin>>str;
    perm(str,0);
    return 0;
}

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to