代码实现#include bits/stdc.h using namespace std; int n; string path; void dfs(int x) { if(x n) { cout path endl; return ; } // 不选 path N; dfs(x1); path.pop_back(); // 选 path Y; dfs(x1); path.pop_back(); } int main() { cin n; dfs(1); return 0; }