Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with C in c++ postfixEval.cpp #include stack.hpp using namespace std; int main(){ freopen(input_postfixEval.txt, r, stdin); string s; int solution; int line_counter = 0;

Need help with C in c++

image text in transcribed

postfixEval.cpp

#include "stack.hpp"

using namespace std;

int main(){ freopen("input_postfixEval.txt", "r", stdin); string s; int solution; int line_counter = 0; while(cin>>solution){ cin>>s; Stack stack; // The input file is in the format "expected_solution postfix_expression"

// We assume that all operands in the input are one digit (so they range from 0 to 9) for(int i=0; i

// Checking whether the value you calculated is correct ... int value = stack.pop();

if(solution == value){ cout

stack.hpp

//#include #include #include #include #include

// Ideally this would not be a huge number, you could also use a vector #define MAXSIZE 100000

using namespace std; template class Stack{ private: T arr[MAXSIZE]; // the actual stack int topIndex; // index of the top element public: Stack(){ topIndex = -1; // constructor }; ~Stack(){}; // destructor void push(T c); // push c to the list T pop(); // return and remove the top element in the stack T peek(); // return the top element in the stack int size(); // returns the size of the stack void display(); // display the stack in stdout };

input_postfixEval.txt

6 33+ 12 62* 1 65- 2 37+2*64+/

(b). (20points) Balancing parenthesis: Complete the balancing.cpp file based on the comments in the file. Specifically, complete the for loop as shown below to check whether s is balanced: 232425for(inti=0;i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions