递归算法---字符串全组合(面试宝典)
/** *求一字符串所有字串的组合 */ #include <stdio.h> #include <string.h> void str_combine(char src[],char out[], int leng, int rec, int start) { int i; for(i=start;i<leng;i++){ out[rec]=src[i]; out[rec+1]='\0'; printf("%s ",out); if(i<leng-1) str_combine(src,out,leng,rec+1,i+1); } } int main() { char src[] = "hart"; int leng = strlen(src); char out[sizeof(src)]={0}; str_combine(src,out,leng,0,0); printf("\n"); return 0; }
相关推荐
steeven 2020-11-10
Tips 2020-10-14
nongfusanquan0 2020-08-18
yedaoxiaodi 2020-07-26
清溪算法君老号 2020-06-27
pengkingli 2020-06-25
yishujixiaoxiao 2020-06-25
清溪算法 2020-06-21
RememberMePlease 2020-06-17
nurvnurv 2020-06-05
SystemArchitect 2020-06-02
码墨 2020-05-29
清溪算法 2020-05-27
choupiaoyi 2020-05-27
清溪算法 2020-05-25
bluewelkin 2020-05-19
dbhllnr 2020-05-15
steeven 2020-05-09
baike 2020-05-09