Sicily 4495. Print permutations

来源:互联网 发布:工作日记软件 编辑:程序博客网 时间:2024/06/05 03:28
#include <iostream>#include <algorithm>#include <cstring>using namespace std;int len;char ch[100];void allsort(int n,int m){if(n >= len){for(int i=0; i < len; i++)cout << ch[i];cout << endl;}else{for(int i=n; i < len; i++){sort(ch+n+1,ch+len);swap(ch[n],ch[i]);allsort(n+1,m);}}}int main(){cin >> ch;len=strlen(ch);allsort(0,len);}

0 0