mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-15 03:10:07 +08:00
formatting source-code for d7af6fdc8c
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
#include <iostream>
|
||||
#include "stack.h"
|
||||
#include "stack.cpp"
|
||||
#include "stack.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
stack<int> stk;
|
||||
cout << "---------------------- Test construct ----------------------" << endl;
|
||||
cout << "---------------------- Test construct ----------------------"
|
||||
<< endl;
|
||||
stk.display();
|
||||
cout << "---------------------- Test isEmptyStack ----------------------" << endl;
|
||||
if(stk.isEmptyStack())
|
||||
cout << "PASS" <<endl;
|
||||
cout << "---------------------- Test isEmptyStack ----------------------"
|
||||
<< endl;
|
||||
if (stk.isEmptyStack())
|
||||
cout << "PASS" << endl;
|
||||
else
|
||||
cout << "FAIL" <<endl;
|
||||
cout << "FAIL" << endl;
|
||||
cout << "---------------------- Test push ----------------------" << endl;
|
||||
cout << "After pushing 10 20 30 40 into stack: "<<endl;
|
||||
cout << "After pushing 10 20 30 40 into stack: " << endl;
|
||||
stk.push(10);
|
||||
stk.push(20);
|
||||
stk.push(30);
|
||||
@@ -24,28 +26,30 @@ int main()
|
||||
cout << "---------------------- Test top ----------------------" << endl;
|
||||
int value = stk.top();
|
||||
if (value == 40)
|
||||
cout << "PASS" <<endl;
|
||||
cout << "PASS" << endl;
|
||||
else
|
||||
cout << "FAIL" <<endl;
|
||||
cout << "FAIL" << endl;
|
||||
cout << "---------------------- Test pop ----------------------" << endl;
|
||||
stk.display();
|
||||
stk.pop();
|
||||
stk.pop();
|
||||
cout << "After popping 2 times: "<< endl;
|
||||
cout << "After popping 2 times: " << endl;
|
||||
stk.display();
|
||||
cout << "---------------------- Test overload = operator ----------------------" << endl;
|
||||
cout << "---------------------- Test overload = operator "
|
||||
"----------------------"
|
||||
<< endl;
|
||||
stack<int> stk1;
|
||||
cout << "stk current: "<< endl;
|
||||
cout << "stk current: " << endl;
|
||||
stk.display();
|
||||
cout << endl << "Assign stk1 = stk "<< endl;
|
||||
cout << endl << "Assign stk1 = stk " << endl;
|
||||
stk1 = stk;
|
||||
stk1.display();
|
||||
cout << endl<< "After pushing 8 9 10 into stk1:" <<endl;
|
||||
cout << endl << "After pushing 8 9 10 into stk1:" << endl;
|
||||
stk1.push(8);
|
||||
stk1.push(9);
|
||||
stk1.push(10);
|
||||
stk1.display();
|
||||
cout << endl << "stk current: " <<endl;
|
||||
cout << endl << "stk current: " << endl;
|
||||
stk.display();
|
||||
cout << "Assign back stk = stk1:" << endl;
|
||||
stk = stk1;
|
||||
|
||||
Reference in New Issue
Block a user