买*

#include<cstdio>
#include<algorithm>
#include <iostream>
#include<cstring>
using namespace std;
int main()
{
    int a,b;
    char shu[6];
    scanf("%s",shu);
    a=strlen(shu);
    sort(shu,shu+a);
    do
    {
          puts(shu);    
    }while(next_permutation(shu,shu+a));
    return 0;
 } 

注释: 体现出C++的好处,一个函数可以解决好多问题

函数next_permutation()是按照字典序产生排列的,并且是从数组中当前的字典序开始依次增大直至到最大字典序。

原文地址:https://www.cnblogs.com/saber114567/p/8390992.html