码迷,mamicode.com
首页 > 其他好文 > 详细

字符串全排列

时间:2018-11-24 20:53:23      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:排列   null   strlen   nbsp   ret   oid   return   void   pre   

void AllSortCore(char *str,int begin,int end);
void AllSort(char *str)
{
    if(str == NULL)
        return ;
    int n = strlen(str);
    AllSortCore(str,0,n-1);
}

void AllSortCore(char *str,int begin,int end)
{
   if(end <=1)
        return ;
   if(begin == end)
    {
        cout<<str<<endl;
    }
    for(int j = begin;j<=end;++j)
    {
        swap(str[j],str[begin]);
        AllSortCore(str,begin+1,end);
        swap(str[j],str[begin]);
    }
}

 

字符串全排列

标签:排列   null   strlen   nbsp   ret   oid   return   void   pre   

原文地址:https://www.cnblogs.com/susidian/p/10013130.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!