#include <iostream> #include <vector> #include "iterator" #include "algorithm" #include "string" #include "stdio.h" using namespace std; ostream_iterator<int> oi(cout,""); int icount = 0; void pailie(vector<int> vectNum,vector<int> &result,int start, int n) { if(start == n) { //copy(result.begin(),result.end(),oi); //cout<<" "; icount++; return; }; int i; for(i=0;i<vectNum.size();i++){ result[start] = vectNum[i]; vector<int> vectNew = vectNum; vectNew.erase(vectNew.begin()+i); pailie(vectNew,result,start+1,n); } } void pailie(vector<int> vectNum,vector<int> &result, int n) { if(vectNum.size()<n) return; pailie(vectNum,result, 0, n); } void main() { int a[9] = {1,2,3,4,5,6,7,8,9}; vector<int> vectNum(a,a+9); int n=6; vector<int> result(n); pailie(vectNum, result,n); cout<<endl<<icount<<endl; }