全排列模板(利用c++函数)

论坛 期权论坛 脚本     
匿名技术用户   2021-1-7 06:39   122   0

next_permutation,别忘记加头文件(#include<algorithm> ),还有sort排序(不然有个别数据无法输出)。

#include<stdio.h> 
#include<string.h> 
#include<algorithm> 
using namespace std; 
int main() 
{ 
    char s[300]; 
    int i,l; 
    while(scanf("%s",s)!=EOF) 
    { 
        sort(s,s+strlen(s)); 
        l=strlen(s); 
        do{ 
            puts(s);  
        }while(next_permutation(s,s+l)); 
    } 
    return 0; 
} 

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP