Skip to content

Latest commit

 

History

History
23 lines (21 loc) · 655 Bytes

File metadata and controls

23 lines (21 loc) · 655 Bytes
#include <iostream>
using std::cin; using std::cout; using std::endl; using std::cerr;
#include <vector>
using std::vector;
#include <iterator>
using std::istream_iterator; using std::ostream_iterator;
#include <algorithm>
using std::sort; using std::copy;

int main() {
    cout << "Please type some value: " << endl;
    istream_iterator<int> int_iter(cin);    //从cin读取int
    istream_iterator<int> eof;      //尾后迭代器
    vector<int> vi;
    while (int_iter != eof)
        vi.push_back(*int_iter++);
    sort(vi.begin(), vi.end());
    ostream_iterator<int> out_iter(cout, " ");
    copy(vi.cbegin(), vi.cend(), out_iter);
}