直接用C++的库就行了,不必自己去递归生成重集的排列,是简单题目。
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
char buffer[60];
int main(void)
{
//freopen("input.dat", "r", stdin);
while(gets(buffer))
{
if(0 == strcmp(buffer,"#"))
break;
if(next_permutation(buffer, buffer+strlen(buffer)))
printf("%s\n", buffer);
else
printf("%s\n", "No Successor");
}
return 0;
}