ex10_07.cpp

来自「Wrox.Ivor.Hortons.Beginning.Visual.C.Plu」· C++ 代码 · 共 41 行

CPP
41
字号
// Ex10_07.cpp
// Exercising a queue container

#include <iostream>
#include <queue>
#include <string>


using std::cin;
using std::cout;
using std::endl;
using std::queue;
using std::string;


int main()
{
  queue<string> sayings;
  string saying;
  cout << "Enter one or more sayings. Press Enter to end." << endl;
  while(true)
  {
    getline(cin, saying);
    if(saying.empty())
      break;
    sayings.push(saying);
  }

  cout << "There are " << sayings.size()
       << " sayings in the queue." 
       << endl << endl;
  cout << "The sayings that you entered are:" << endl;
  while(!sayings.empty())
  {
    cout << sayings.front() << endl;
    sayings.pop();
  }

  return 0;
}

⌨️ 快捷键说明

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