#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
void Foo(const char*str){
string s=str;
cout<<s<<endl;
while(next_permutation(s.begin(),s.begin()+s.size())){
cout<<s<<endl;
}
return ;
}
int main(){
const char str[]="abc";
Foo(str);
return 0;
}
#include<iostream>
using namespace std;
void Foo(char *str,char *begin)
{
if(*begin == '\0')
cout<<str<<endl;
else
for(char* p = begin; *p != '\0'; p++)
{
swap(*begin,*p);
Foo(str, begin+1);
swap(*begin,*p);
}
}
int main()
{
char *str=new char[100];
cin>>str;
Foo(str,str);
return 0;
}
#include<iostream>
using namespace std;
void swap(char *a,char *b)
{
char t=*a;
*a=*b;
*b=t;
}
int ISswap(char *a,int begin,int end)
{
for(int i=0;i<end;i++)
{
if(a[i]==a[end])
{return 0;}
}
return 1;
}
void allrange(char *p,int k,int m)
{
if(k==m)
{
static int n=1;
cout<<p;
}
else
{
for(int i=k;i<=m;i++)
{
if(ISswap(p,k,i))
{
swap(p+k,p+i); allrange(p,k+1,m); swap(p+k,p+i); }
}
}
}
int main()
{
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void swap(char *a, char *b)
{
if (a != b) {
char c = *a;
*a = *b;
*b = c;
}
}
void dfs(char *str, int kth, int len)
{
if (kth == len) {
printf("%s\n", str);
return;
}
for (int i = 0; i <= kth; ++i) {
swap(&str[i], &str[kth]);
dfs(str, kth + 1, len);
swap(&str[i], &str[kth]);
}
}
int main(void)
{
char str[] = "abc";
dfs(str, 0, strlen(str));
}
/**
* @author revoid
* @param sb
* @param ctrs
* @param btrs
* @param begin
* @param end
*/
public static void fooGet(StringBuilder sb, char []ctrs, boolean[]btrs, int begin, int end)
{
if(begin == end)
{
System.out.println(sb);
return;
}
for(int i = 0; i < ctrs.length; i++)
{
if(false == btrs[i])
{
sb.append(ctrs[i]);
btrs[i] = true;
fooGet(sb, ctrs, btrs, begin + 1, end);
sb.deleteCharAt(sb.length() - 1);
btrs[i] = false;
}
}
}
#include <iostream>
#include <algorithm>
#include <string>
void Foo(const char * str)
{
using namespace std;
if (str==NULL || *str==NULL)
return;
string s(str);
int c=0;
sort(s.begin(),s.end());
cout<<s<<endl;
c++;
for (;next_permutation(s.begin(),s.end());)
{
cout<<s<<endl;
c++;
}
cout<<c<<"种排列"<<endl;
}
int main()
{
using namespace std;
string s;
cin>>ws;
getline(cin,s);
Foo(s.c_str());
return 0;
}