#include <iostream>
#include<vector>
using namespace std;
int cnt=0;
string a[10]={"xie","wang","song","guo","liu","he","1","2","3","4"};//全局变量,便于变量函数间操作
void printv(vector<string> &v)//输出函数
{
for(int i=0;i<v.size();i++)
{
cout<<v[i]<<endl;
}
cout<<endl<<endl<<endl;
}
int small(int n,vector<string> &v)//统计起始循环值
{
for(int i=0;i<n;i++)
{
if(a[i]==v.back())
{
return i;
}
}
}
void pick(int n,vector<string> &v,int topick)//核心代码
{
if(topick==0)//调用输出
{
cnt++;
printv(v);
return;//极为关键,跳出层层递归值力气,万不可缺
}
int start;
if(v.empty())//统计起始循环值
{
start=0;
}
else{
start=small(n,v)+1;
}
for(int j=start;j<n;j++)//核心中的核心,topick层递归,逐层跳出,区别于迭代,迭代是分支枚举,递归是深度搜索
{
v.push_back(a[j]);
pick(n,v,topick-1);
v.pop_back();
}
}
int main()
{
vector<string>v;
pick(10,v,5);
cout<<cnt;
}