⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter5-10.cpp

📁 大量程序实例
💻 CPP
字号:
//文件名:CHAPTER5-10.cpp
#pragma warning(disable:4786)
#include <stack>
#include <iostream>
using namespace std ;
typedef stack<int> STACK_INT;
void main()
{
   STACK_INT stack1;
   cout << "stack1.empty() returned " <<
      (stack1.empty()? "true": "false") << endl;  // Function 3
   cout << "stack1.push(2)" << endl;
   stack1.push(2);
   if (!stack1.empty())                           // Function 3
      cout << "stack1.top() returned " <<
      stack1.top() << endl;                       // Function 1
   cout << "stack1.push(5)" << endl;
   stack1.push(5);
   if (!stack1.empty())                           // Function 3
      cout << "stack1.top() returned " <<
      stack1.top() << endl;                       // Function 1
   cout << "stack1.push(11)" << endl;
   stack1.push(11);
   if (!stack1.empty())                           // Function 3
      cout << "stack1.top() returned " <<
      stack1.top() << endl;                       // Function 1
  // Modify the top item. Set it to 6.
   if (!stack1.empty()) {                         // Function 3
      cout << "stack1.top()=6;" << endl;
      stack1.top()=6;                             // Function 1
   }
   // Repeat until stack is empty
   while (!stack1.empty()) {                      // Function 3
      const int& t=stack1.top();                  // Function 2
      cout << "stack1.top() returned " << t << endl;
      cout << "stack1.pop()" << endl;
      stack1.pop();
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -