Print the balanced bracket expression using given brackets | C # implementation of the approach ; Function to print balanced bracket expression if it is possible ; If the condition is met ; Print brackets of type - 1 ; Print brackets of type - 3 ; Print brackets of type - 4 ; Print brackets of type - 2 ; If the condition is not met ; Driver code
using System ; class GFG { static void printBalancedExpression ( int a , int b , int c , int d ) { if ( ( ( a == d ) && ( a != 0 ) ) || ( ( a == 0 ) && ( c == 0 ) && ( d == 0 ) ) ) { for ( int i = 1 ; i <= a ; i ++ ) Console . Write ( " ( ( " ) ; for ( int i = 1 ; i <= c ; i ++ ) Console . Write ( " ) ( " ) ; for ( int i = 1 ; i <= d ; i ++ ) Console . Write ( " ) ) " ) ; for ( int i = 1 ; i <= b ; i ++ ) Console . Write ( " ( ) " ) ; } else Console . Write ( - 1 ) ; } public static void Main ( ) { int a = 3 , b = 1 , c = 4 , d = 3 ; printBalancedExpression ( a , b , c , d ) ; } }