感谢微信平台:一天一道算法题---每天多一点进步----
problem:
从M个不同的字符中任取N个字符的所有组合
analyse:
微信这边 没有给出一些思路 而且我也觉得它提供的代码 可读性不高... 而且好像 实现出来并没有达到预计效果
我准备 自己看下 能不能写出来 再贴上去 可能要等明天晚上吧 =-=
时隔好多天的代码 贴上 =-=
分别是 考虑 排序的时候元素是否考虑有序的情况与不考虑的情况 只有稍许区别
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 // 从7个的字符串选取3个 任意组合 2 #include <iostream> 3 #include <algorithm> 4 using namespace std; 5 6 char str[20] = {'a','b','C','B','2','1' }; 7 char temp[20]; 8 9 void printStr( char* temp , int m ) 10 { 11 for( int i = 0 ; i<m ; i++ ) 12 { 13 cout<<temp[i]; 14 } 15 cout<<endl; 16 } 17 18 bool judge( int k , char var ) 19 { 20 for( int i = 0 ; i<k ; i++ ) 21 { 22 //if( temp[i]==var ) // 考虑顺序排序 如1 2 3 与 2 1 3都输出 23 // return false; 24 if( temp[i]!=var ) // 不考虑 排序 1 2 3与 2 1 3 只输出 1 2 3一种情况 25 return false; 26 } 27 return true; 28 } 29 30 void multi( int t , int n , int m ) 31 { 32 if( t==m ) 33 { 34 temp[t] = '