2012年10月27日
摘要: 全排列,经常会碰到的算法题,比如给定a,b,c,则一共有abc,acb,bca,bac,cab,aba六种方式; 先确定a,然后对bc进行处理;将a和b交换,处理ac;每一步处理完之后,将之前的交换恢复,就得到如下的算法:void Perm(Tpye arr [],int k,int m){ if(k==m) //不断缩小处理范围 { for(int i=0;i<=m;i++) cout<<arr[i]; cout<<endl; } else { for(int j... 阅读全文
posted @ 2012-10-27 14:01 CodeAnt 阅读(155) 评论(0) 推荐(0) 编辑