Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include <iostream> #if LAB6_TEST1 # include \"StackLinked.h\" #else # include \

ID: 3532720 • Letter: #

Question


#include <iostream>


#if LAB6_TEST1

# include "StackLinked.h"

#else

# include "StackArray.h"

#endif


//--------------------------------------------------------------------


bool delimitersOk ( const string &expression );


//--------------------------------------------------------------------


int main()

{

string inputLine; // Input line

char ch; // Holding pen for input chars


cout << "This program checks for properly matched delimiters."

<< endl;


while( cin )

{

cout << "Enter delimited expression (<EOF> to quit) : "

<< endl;


// Read in one line

inputLine = "";

cin.get(ch);

while( cin && ch != ' ' )

{

inputLine = inputLine + ch;

cin.get(ch);

}


if( ! cin ) // Reached EOF: stop processing

break;

  

if ( delimitersOk (inputLine) )

cout << "Valid" << endl;

else

cout << "Invalid" << endl;

}


return 0;

}


//--------------------------------------------------------------------

// Note: we used the term "braces" to describe '[' and ']'. It would

// have been better to use the term "brackets". The program can be

// easily modified to process any set of matching delimiters.

//--------------------------------------------------------------------


// Insert your delimitersOk function below





Explanation / Answer

Bool delimitersOk(string in)

{

stack* head=NULL,tail=NULL,node=NULL;

char c;

int i =0;

while(in[i] !=