1 vector<int>path; 2 void bianli(int n,int index){ 3 if(n<0){ 4 return; 5 } 6 if(n==0){ 7 path.push_back(index); 8 for(int i=0;i<path.size();i++){ 9 cout<<path[i]<<" "; 10 } 11 cout<<endl; 12 path.pop_back(); 13 return; 14 } 15 if(index==1||index==2) { 16 path.push_back(index); 17 } 18 bianli(n-1,1); 19 bianli(n-2,2); 20 path.pop_back(); 21 } 22 int main(){ 23 int n; 24 bianli(5,0); 25 return 0; 26 }