C++ Programming, Stack queue and deque
C++ Programming, Stack queue and deque
Improve the error code below, you can also create custom methods in the main class. See attached photo for the instructions.
main.cpp: In function ‘int main(int, char**)’: main.cpp:17:15: error: expected primary-expression before ‘char’ stack<char> s; ^~~~ main.cpp:21:17: error: ‘s’ was not declared in this scope s.push(x[i]); ^ main.cpp:22:37: error: ‘s’ was not declared in this scope else if (x[i]==')' and !s.empty()) ^ main.cpp:44:16: error: ‘s’ was not declared in this scope return (s.empty()); ^ main.cpp:47:14: error: jump to case label [-fpermissive] case 1: ^ main.cpp:16:16: note: crosses initialization of ‘std::__cxx11::string x’ string x=str; ^ main.cpp:56:14: error: jump to case label [-fpermissive] case 2: ^ main.cpp:16:16: note: crosses initialization of ‘std::__cxx11::string x’ string x=str; ^ main.cpp:74:14: error: jump to case label [-fpermissive] case 3: ^ main.cpp:16:16: note: crosses initialization of ‘std::__cxx11::string x’ string x=str; ^ main.cpp:90:14: error: jump to case label [-fpermissive] case 4: ^ main.cpp:16:16: note: crosses initialization of ‘std::__cxx11::string x’ string x=str; ^ main.cpp:110:14: error: jump to case label [-fpermissive] case 5: ^ main.cpp:16:16: note: crosses initialization of ‘std::__cxx11::string x’ string x=str; ^ main.cpp:130:14: error: jump to case label [-fpermissive] case 6: ^ main.cpp:16:16: note: crosses initialization of ‘std::__cxx11::string x’ string x=str; ^ g++: error: main.o: No such file or directory g++: fatal error: no input files compilation terminated.
main.cpp
![main.cpp: In function 'int main(int, char**)':
main.cpp:17:15: error: expected primary-expression before char'
stack<char> s;
main.cpp:21:17: error: 's' was not declared in this scope
s. push(x[i]);
main.cpp:22:37: error: 's was not declared in this scope
else if (x[i]--')' and !s.empty())
main.cpp:44:16: error: 's was not declared in this scope
return (s.empty());](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2cb11186-80ff-4474-bc75-6eff69002743%2F8fc1cadf-bf9a-4bcc-8e8b-3bdfa942ad9b%2F0qj50i_processed.png&w=3840&q=75)
![Additionally, you are also going to solve the Brackets Problem in
the case O of the main.cpp file where you have to identify
whether a given string that contains brackets is valid or not.
Brackets may be parentheses ( and ), curly brackets { and },
and square brackets [ and ]. Each opening symbol must match
its corresponding closing symbol. For example, a left bracket,
"L" must match a corresponding right bracket, ")," as in the
following expression: [0]
Take note of the three considerations that will make the string
invalid: a mismatch where the closing bracket did not match
what was in the top of the stack (e.g. "(1)"), an excess opening
where we have completed checking the string where there
should have been more closing bracket/s (e.g. "(0"), and an
excess closing where we found a closing bracket but there's no
opening bracket to match it with (e.g. "0)").
Using the methods of a stack and your SLL implementation,
create a separate program that will print accepted if a given
string is valid exclusively in terms of brace pairing and
otherwise, print not accepted.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2cb11186-80ff-4474-bc75-6eff69002743%2F8fc1cadf-bf9a-4bcc-8e8b-3bdfa942ad9b%2Ftrr7l1_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









