codeup【递归入门】出栈序列统计_codeup编程_战斗的咸鱼的博客-CSDN博客
#include<iostream>
using namespace std;
int n,sum,ans;
void dfs(int out,int in,int not_in){
if(out==n){
ans++;
return;
}
if(in>0) dfs(out+1,in-1,not_in);
if(not_in>0&&in<n) dfs(out,in+1,not_in-1);
}
int main(){
cin>>n;
dfs(0,0,n);
cout<<ans<<endl;
return 0;
}