1.快速构建排列树:

 1     void BackTrace(int t){//排列树
 2         if(t<N){//如果没有到叶子结点
 3             for(int i=t;i<N;i++){
 4                 swap(x,t,i);
 5                 BackTrace(t+1);
 6                 swap(x,i,t);
 7             }
 8         }else{
 9             PrintNums(x);
10         }
11     }

实例输出:

012
021
102
120
210
201

 


 

相关文章:

  • 2021-12-27
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-09-18
  • 2022-12-23
  • 2021-12-13
相关资源
相似解决方案