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 #include #include #include #include using namespace std;

int main() { string input; int num = 0, op = 0, value = 0; vector numbers;

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!