Question
hello there I have a question,, I want to create a programme to check it is a stack or not in c++ Sample Input Create
hello there
I have a question,, I want to create a programme to check it is a stack or not in c++
Sample Input
Create a file with the following lines and use it as input into your program. Please use at least these as your test cases before submitting your code in Canvas.
4 1 2 1 1 2 1 2 2 6 1 5 1 10 1 12 2 10 2 5 2 12 2 1 8 2 8
Sample Output
stack not stack stack
and this is my program so far but i got stuck on the middle
#include
int main() { string input; int num = 0, op = 0, value = 0; vector
fstream textfile; textfile.open("testcases.txt");
if (textfile) { cout << "succeed"; getline(cin, input); stringstream(input) >> num; bool stack = true; for (int i = 0; i < num; i++) { getline(cin, input); stringstream(input) >> op >> value; if (op == 1) { numbers.push_back(value); }else if (op == 2) { if (numbers.at(numbers.size() -1) != value) { stack = false; }
}
} }
system("pause"); return 0; }
can someone help me and tell me what is my problems
thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started