求一个数的下一个排列!
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
const int maxn = 55;
char src[maxn];
int main()
{
while (scanf("%s", src) == 1)
{
if (src[0] == '#')
break;
int i;
int len = 0;
for (i = 0; src[i]; ++i)
++len;
if (next_permutation(src, src + len))
{
for (i = 0; i < len; ++i)
printf("%c", src[i]);
printf("\n");
}
else
{
printf("No Successor\n");
}
}
return 0;
}