#include <iostream>
#include <string>
using namespace std;
// Functie care verifica daca doua paranteze sunt corect inchise
bool isMatchingPair(char character_1, char character_2)
{
if (character_1 == '(' && character_2 == ')')
return true;
else
return false;
}
// Functia recursiva pentru a genera siruri de paranteze corect inchise
void generate_parantheses(int n, int open_brackets, int close_brackets, string str)
{
if (close_brackets == n)
{
// print the generated parantheses string
cout << str << endl;
return;
}
if (open_brackets > close_brackets) {
generate_parantheses(n, open_brackets, close_brackets + 1, str + ")");
}
if (open_brackets < n) {
generate_parantheses(n, open_brackets + 1, close_brackets, str + "(");
}
}
// Driver code
int main()
{
int n = 3;
generate_parantheses(n, 0, 0, "");
return 0;
}