首页 > 学院 > 开发设计 > 正文

字符串的全排列

2019-11-08 02:35:55
字体:
来源:转载
供稿:网友

输入你想输入的字符的个数,输出它的全排列形式,输出一共有多少种方法

#include<algorithm>

#include<cstdio>

using namespace std;

int ans=0;

int main()

{

char s[200];

int n;

while(scanf("%d %s",&n,s)!=EOF)

{

sort(s,s+n);

do

  puts(s);

ans++;

}while(next_permutation(s,s+n));

 PRintf("%d",ans);

}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    return 0;

}


上一篇:古堡算式

下一篇:猜灯谜

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表