my code would give just one output
#include
#include
using namespace std;
void go(string s,int open,int close,int pos,int n)
{
if(n==0)
cout<<""<<endl;
if(pos==2*n)
{
if(open==close)
cout<<s<<endl;
else
return;
}
if(open>close)
{
go(s+")",open,close+1,pos+1,n);
}
else if(open<n)
go(s+"(",open+1,close,pos+1,n);
}
int main() {
string s="(";
int open=1;
int close=0;
int pos=1;
int n;
cin>>n;
go(s,open,close,pos,n);
return 0;
}