Advertisement
Neveles

Untitled

Mar 5th, 2020
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. #include <iostream>
  2. #include "StackArray.h"
  3. #include "StackList.h"
  4.  
  5. using namespace std;
  6.  
  7. bool testBalanceBrackets(const char* text, string gear, int maxDeep = 30);
  8.  
  9. int main()
  10. {
  11. cout << "Input stack type to work with. Either \"Array\" or \"List\": ";
  12. string stackType = "";
  13. cin >> stackType;
  14.  
  15. if (stackType != "Array" && stackType != "List")
  16. {
  17. cerr << "Error! Stack type is incorrect!";
  18. return -1;
  19. }
  20.  
  21. const char* test1 = "";
  22. cout << test1;
  23. cout << (testBalanceBrackets(test1, stackType) ? " right\n" : " wrong\n") << endl;
  24.  
  25. const char* test2 = "( )";
  26. cout << test2;
  27. cout << (testBalanceBrackets(test2, stackType) ? " right\n" : " wrong\n") << endl;
  28.  
  29. const char* test3 = "( ( [] ) )";
  30. cout << test3;
  31. cout << (testBalanceBrackets(test3, stackType) ? " right\n" : " wrong\n") << endl;
  32.  
  33. const char* test4 = "( ( [ { } [ ] ( [ ] ) ] ) )";
  34. cout << test4;
  35. cout << (testBalanceBrackets(test4, stackType) ? " right\n" : " wrong\n") << endl;
  36.  
  37. const char* test5 = "( ( [ { } [ ] ( [ ] ) ] ) ) )";
  38. cout << test5;
  39. cout << (testBalanceBrackets(test5, stackType) ? " right\n" : " wrong\n") << endl;
  40.  
  41. const char* test6 = "( ( [ { } [ ] ( [ ] ) ] )";
  42. cout << test6;
  43. cout << (testBalanceBrackets(test6, stackType) ? " right\n" : " wrong\n") << endl;
  44.  
  45. const char* test7 = "( ( [ { ] [ ] ( [ ] ) ] ) )";
  46. cout << test7;
  47. cout << (testBalanceBrackets(test7, stackType) ? " right\n" : " wrong\n") << endl;
  48.  
  49. const char* test8 = "( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (";
  50. cout << test8;
  51. cout << (testBalanceBrackets(test8, stackType) ? " right\n" : " wrong\n") << endl;
  52.  
  53. const char* test9 = "( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )";
  54. cout << test9;
  55. cout << (testBalanceBrackets(test9, stackType) ? " right\n" : " wrong\n") << endl;
  56.  
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement