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

📄 soln10_1.cpp

📁 Wrox.Ivor.Hortons.Beginning.Visual.C.Plus.Plus.2008 With sourcecode
💻 CPP
字号:
// Soln 10_1.cpp
// This uses stream iterator for input and output and a back inserter to transfer
// data from the input stream to the list container.
#include <iostream>
#include <iterator>
#include <list>              

using std::cout;
using std::endl;
using std::cin;
using std::list;
using std::istream_iterator;
using std::ostream_iterator;
using std::back_inserter;

int main()
{
  list<char> characters;
  cout << "Enter characters then Enter followed by Ctrl+Z to end:" << endl;

  istream_iterator<char> charsInput(cin), charsEnd;   // Input stream iterator for character input
  
  copy(charsInput, charsEnd, back_inserter<list<char>>(characters));

  characters.sort();

  // Output stream iterator for characters with output separated by spaces
  ostream_iterator<char> out(cout, " ");

  // Output the contents of the container
  cout << "You entered the following characters:" << endl;
  copy(characters.begin(), characters.end(), out);
  cout << endl;

   return 0;
}

⌨️ 快捷键说明

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