public void F(int num,int n,String str) {
//递归先写终止条件
if(num>n)
{
return ;
}
if(num==n)
{
System.out.println(str);
return;
}
//往后递归
F(num+1, n, str+“1”);//这是新字符串
F(num+2, n, str+“2”);
}
来源:CSDN
作者:qq_42265608
链接:https://blog.csdn.net/qq_42265608/article/details/103591629