answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: Delimiter Matching in c plus plus using stack?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Representation of stack data structure in c plus plus?

Stack is an abstract data type that allows you to input and output data in a way that the first data which was placed in the stack will be the last one to get out. We use physical examples of stack in our daily lives such as the stack of dishes or stack of coins where you only add or remove objects from the top of the stack. You can see the implementation in c++ in related links, below.


How you use stack in c plus plus classes?

It would be easier to manipulate the stack in assembly language rather than C++.


How do you determine when a stack is empty in c plus plus?

#include<iostream> #include<stack> #include<cassert> int main () { std::stack<unsigned> s; assert (s.empty()==true); s.push (42); assert (s.empty()==false); s.pop (); assert (s.empty()==true); }


Write a c plus plus function to reverse the contents of a stack using two additional stacks?

The following function template will reverse any stack of type T: template<typename T> void reverse_stack (sd::stack<T>& A) // Pass by reference! { std::stack<T> B, C; // Two additional stacks (initially empty). while (!A.empty()) { B.push (A.top()); A.pop(); } while (!B.empty()) { C.push (B.top()); B.pop(); } while (!C.empty()) { A.push (C.top()); C.pop(); } // A is now in reverse order. } A more efficient method is to pop the stack onto a queue. template<typename T> void reverse_stack_optimised (sd::stack<T>& A) // pass by reference! { std::queue<T> B; while (!A.empty()) { B.push_back (A.top()); A.pop(); } while (!B.empty()) { A.push (B.front()); B.pop(); } // A is now in reverse order. }


What is the C plus plus programs to implement the stack ADT using a singly linked list?

#include<iostream> #include<time.h> #include<forward_list> int main() { // seed random number generator srand ((unsigned) time(NULL)); // a forward_list is a singly-linked list std::forward_list<int> stack; // push 10 integers onto stack for (int loop=0; loop<10; ++loop) { int num=rand(); std::cout<<"Pushing "<<num<<std::endl; stack.push_front (num); } // pop all integers while (!stack.empty()) { std::cout<<"Popping "<<stack.front()<<std::endl; stack.pop_front(); } }

Related questions

How do you use scanf with delimiter in c plus plus Please provide a basic example with output?

scanf does not employ a delimiter. It simply reads formatted input from std::cin.


Representation of stack data structure in c plus plus?

Stack is an abstract data type that allows you to input and output data in a way that the first data which was placed in the stack will be the last one to get out. We use physical examples of stack in our daily lives such as the stack of dishes or stack of coins where you only add or remove objects from the top of the stack. You can see the implementation in c++ in related links, below.


Does PlayStation plus stack?

Yes, it is possible to purchase, or 'stack', additional time to your Plus membership


How you use stack in c plus plus classes?

It would be easier to manipulate the stack in assembly language rather than C++.


'write a simple program for stack operation in c plus plus?

void push(int y) { if(top>stackSize) { cout<<"stack full"<<endl; return; } else { top++; stack[top]=y; } } int pop() { int a; if(top<=0) { cout<<"stack is empty"<<endl; return 0; } else { a=stack[top]; top--; } return(a); }


Represent a stack in c plus plus?

Use a vector with a base class type. Any objects derived from the base class can be pushed and popped from the vector just as you would from a stack.


How should you design a scientific calculator using C plus plus?

The easiest way to implement a calculator is an RPN calculator (enter the numbers first, perform the operation last). You need a last-in-first-out stack (there's a "stack" class in C++, but you can also implement your own using an array or a linked list), and a set of functions that pop the last elements from the stack and push the result (e.g. Add() pops the last 2 values and pushes their addition).You'll need the math.h library for scientific operations.


What is pop in C plus plus?

"Pop" allows you to remove items off of the stack. The stack is an area in memory that contains the information of a program, such as function names and instructions, the values of variables, etc. The opposite of pop is "push". This allows you to add items to the stack.


How do you determine when a stack is empty in c plus plus?

#include<iostream> #include<stack> #include<cassert> int main () { std::stack<unsigned> s; assert (s.empty()==true); s.push (42); assert (s.empty()==false); s.pop (); assert (s.empty()==true); }


In c plus plus what is meant by stack?

The stack is a region of memory organized as a first-in-last-out (LIFO) structure which stores return information, parameters, and local variables. Since it is a LIFO structure, it is nested, i.e. "stacked", similar to how a stack of papers on your desk would be stacked, and if you could only deal with the top-most paper on the stack. At the language level, C, C++, JAVA, etc., you generally do not even think about the implementation of the stack - it is just there - and it does what it needs in terms of return state, registers, parameters, and automatic or temporary variables.


Write a c plus plus function to reverse the contents of a stack using two additional stacks?

The following function template will reverse any stack of type T: template<typename T> void reverse_stack (sd::stack<T>& A) // Pass by reference! { std::stack<T> B, C; // Two additional stacks (initially empty). while (!A.empty()) { B.push (A.top()); A.pop(); } while (!B.empty()) { C.push (B.top()); B.pop(); } while (!C.empty()) { A.push (C.top()); C.pop(); } // A is now in reverse order. } A more efficient method is to pop the stack onto a queue. template<typename T> void reverse_stack_optimised (sd::stack<T>& A) // pass by reference! { std::queue<T> B; while (!A.empty()) { B.push_back (A.top()); A.pop(); } while (!B.empty()) { A.push (B.front()); B.pop(); } // A is now in reverse order. }


What do you get if you get four numbers and the mega ball on your Mega Millions ticket?

Yes 150.00 for 4 matching numbers. 3 #s plus powerball or 4#s with no matching power ball.