题目:
http://poj.org/problem?id=1731
这个题可以直接用STL做。
next_permutation(begin(),end())
prev_permutation(begin(),end())
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
char str[210];
while(scanf("%s",str)!=EOF)
{
int l = strlen(str);
sort(str,str+l);
puts(str);
while(next_permutation(str,str+l))
{
puts(str);
}
}
return 0;
}