Server IP : 172.16.15.8 / Your IP : 18.189.186.247 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/grpatillo/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// CopyNth Test Driver for either Stack implementation // // Make sure MAXSTACK = 6 in class implementation #include <iostream> //#include "stackarray.h" // to test array implementation #include "stackll.h" // to test array implementation using namespace std; int main () { StackType<char> chstack; // test stack char copych; // holds character viewed by CopyNth // Push some items chstack.Push ('A'); chstack.Push ('B'); chstack.Push ('C'); chstack.Push ('D'); chstack.Push ('E'); chstack.Push ('F'); // Do some CopyNth calls - stack has 6 values cout << "\nTesting CopyNth for stack with 6 items"; chstack.CopyNth (6, copych); cout << "\n\nThe 6th value should be A and it is " << copych; chstack.CopyNth (1, copych); cout << "\n\nThe 1st value should be F and it is " << copych; chstack.CopyNth (3, copych); cout << "\n\nThe 3rd value should be D and it is " << copych; // Pop until stack has 4 values chstack.Pop (); chstack.Pop (); // Do some CopyNth calls chstack.CopyNth (4, copych); cout << "\n\nThe 4th value should be A and it is " << copych; chstack.CopyNth (3, copych); cout << "\n\nThe 3rd value should be B and it is " << copych; chstack.CopyNth (2, copych); cout << "\n\nThe 2nd value should be C and it is " << copych; chstack.CopyNth (1, copych); cout << "\n\nThe 1st value should be D and it is " << copych; chstack.Pop (); chstack.Pop (); chstack.Pop (); chstack.Pop (); // Stack should now be empty if (chstack.IsEmpty()) cout << "\n\nStack is empty, as it should be\n\n"; else cout << "\n\nStack isn't empty, but should be - uh-oh!\n\n"; return 0; }