fork(5) download
  1. i,j,s;f(n){for(char a[31]={};++i%(1<<2*n);s||puts(a))for(j=s=0;~s&&j<2*n;)s+=1-(a[j]=40+(i>>j++)%2)%2*2;}
  2.  
  3. int main() {
  4. f(0);f(1);f(2);f(3);f(4);f(3);f(2);f(1);f(0);
  5. return 0;
  6. }
Success #stdin #stdout 0s 2112KB
stdin
Standard input is empty
stdout
()
()()
(())
()()()
(())()
()(())
(()())
((()))
()()()()
(())()()
()(())()
(()())()
((()))()
()()(())
(())(())
()(()())
(()()())
((())())
()((()))
(()(()))
((()()))
(((())))
()()()
(())()
()(())
(()())
((()))
()()
(())
()