입력 > 3
결과
((()))
(()())
(())()
()(())
()()()
코드
#include <iostream>
#include <string>
using namespace std;
int n;
void DFS(int s = 0, int e = 0, string str = "")
{
if (s > n ||
e > n ||
e > s)
return;
if (s == n &&
e == n)
cout << str << endl;
else
{
DFS(s + 1, e, str + '(');
DFS(s, e + 1, str + ')');
}
}
int main()
{
n = 3;
DFS();
}
뷰지에 뷰지에 부지 ㄷㄷ - dc App