Parenthesis/Brackets Matching using Stack algorithm

前端 未结 30 2703
你的背包
你的背包 2020-11-27 11:39

For example if the parenthesis/brackets is matching in the following:

({})
(()){}()
()

and so on but if the parenthesis/brackets is not mat

30条回答
  •  情深已故
    2020-11-27 12:22

    here is my solution using c++ if brackets are matched then returns true if not then gives false

    #include 
    #include 
    #include 
    using namespace std;
    
    int matchbracket(string expr){
        stack st;
        int i;
        char x;
        for(i=0;i>expr;
     
     if(matchbracket(expr)==1)
      cout<<"\nTRUE\n";
      else
      cout<<"\nFALSE\n";
    }
    

提交回复
热议问题