本文整理汇总了C++中Stack::CleanStack方法的典型用法代码示例。如果您正苦于以下问题:C++ Stack::CleanStack方法的具体用法?C++ Stack::CleanStack怎么用?C++ Stack::CleanStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack::CleanStack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MainFunc
int MainFunc()
{
std::cout << " "
<< " 00000000 0000000000000 0000 00000000 0000 000000 "
<< " 000000000000 0000000000000 000000 00000000000 0000 000000 "
<< " 000 0000 0000 0000000 00000 0000 0000 000000 "
<< " 0000 0000 00000000 00000 0000 0000000000 "
<< " 000000000 0000 000000000 0000 000000000 "
<< " 00000000 0000 0000 00000 0000 000000000 "
<< " 000000 0000 0000 00000 0000 0000000000 "
<< " 0000 0000 0000 0000000000000 00000 0000 0000 00000 "
<< " 0000 0000 0000 00000000000000 00000 0000 0000 00000 "
<< " 00000000000 0000 00000 0000000 00000000000 0000 00000 "
<< " 0000000 0000 0000 0000000 0000000 0000 00000 "
<< " ";
UC c = '1';
cout <<"This program working with stack which may be contained " << N << " elements\n\n";
cout <<"Main menu. Please choose what operation do you want to be completed:\n"
<<"1-Show content of stack.\n"
<<"2-Clean content of stack.\n"
<<"3-Push element in stack.\n"
<<"4-Pop element in stack.\n"
<<"5-Top element in stack.\n"
<<"6-Fullness of stack.\n"
<<"7-Show main menu.\n"
<<"8-About.\n"
<<"0-Exit.\n"
<<" -> ";
Stack s;
while(c != '0')
{
c = _getch();
cout << (char)c << endl;
UC ct;
switch(c)
{
case '1':
if( !s.PrintStack( ) )
cout << "Stack is empty.\n -> ";
break;
case '2':
if( s.CleanStack( ) )
cout << "Operation completed.\n -> ";
else
cout << "Stack was already empty.\n -> ";
break;
case '3':
cout << "Enter symbol:\n -> ";
ct = _getch();
cout << ct << "\n";
if( !s.PushElemInStack(ct) )
cout << "Stack is full.\n -> ";
else
cout << "Operation completed.\n -> ";
break;
case '4':
ct = s.PopElemFromStack();
if(ct == '\0')
cout << "Nothing to remove. Stack was already empty.\n -> ";
else
cout << "Operation completed. Removed symbol: \'" << ct << "\'.\n -> ";
break;
case '5':
ct = s.TopStack();
if(ct == '\0')
cout << "Stack is empty.\n -> ";
else
cout << "Top of the stack: \'" << ct << "\'.\n -> ";
break;
case '6':
if( s.StackIsEmpty() == 1 )
cout << "Stack is empty.\n -> ";
else if( s.StackIsEmpty() == -1 )
cout << "Stack is full.\n -> ";
else
cout << "Stack is not full.\n -> ";
break;
case '7':
cout << "Main menu. Please choose what operation do you want to be completed:\n"
<< "1-Show content of stack.\n"
<< "2-Clean content of stack.\n"
<< "3-Push element in stack.\n"
<< "4-Pop element in stack.\n"
<< "5-Top element in stack.\n"
<< "6-Fullness of stack.\n"
<< "7-Show main menu.\n"
<< "8-About.\n"
<< "0-Exit.\n"
<< " -> ";
break;
case '8':
cout << "GlobalLogic Base Camp. Task 5.\n -> ";
break;
case '0':
cout << "Thank you for choosing our application.\n";
_getch();
return 0;
default:
cout << "Input error. Try again.\n -> ";
break;
//.........这里部分代码省略.........