Algorithms_in_C++  1.0.0
Set of algorithms implemented in C++.
paranthesis_matching.cpp File Reference

Perform paranthesis matching. More...

#include <iostream>
#include <cstring>
Include dependency graph for paranthesis_matching.cpp:

Macros

#define MAX   100
 

Functions

char opening (char ch)
 
int main ()
 
char stack [MAX]
 
int stack_idx = -1
 pointer to track stack index
 
void push (char ch)
 push byte to stack variable
 
char pop ()
 pop a byte out of stack variable
 

Detailed Description

Perform paranthesis matching.

Note
Do not know the application of this, however.
Implementation is C-type and does not utilize the C++ constructs
Todo:
implement as a C++ class

Macro Definition Documentation

◆ MAX

#define MAX   100

check number

Function Documentation

◆ opening()

char opening ( char  ch)

return opening paranthesis corresponding to the close paranthesis

Parameters
[in]chclosed paranthesis character
36  {
37  switch (ch) {
38  case '}':
39  return '{';
40  case ']':
41  return '[';
42  case ')':
43  return '(';
44  case '>':
45  return '<';
46  }
47  return '\0';
48 }

Variable Documentation

◆ stack

char stack[MAX]

-----------— stack -----------— global stack