posts - 225, comments - 62, trackbacks - 0, articles - 0
   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

号称唯美主义的杰作

Posted on 2006-05-06 18:43 魔のkyo 阅读(459) 评论(1)  编辑 收藏 引用 所属分类: STL
先记下来,慢慢研究
#include <iostream>
#include 
<vector>
#include 
<algorithm>
#include 
<iterator>

using namespace std; 

int main(void)
{
    typedef vector
<int>    int_vector;
    typedef istream_iterator
<int>    istream_itr;
    typedef ostream_iterator
<int>    ostream_itr;
    typedef back_insert_iterator
< int_vector > back_ins_itr;
    
// STL中的vector容器
    int_vector num;
    
// 从标准输入设备读入整数,
    
// 直到输入的是非整型数据为止
    copy(istream_itr(cin), istream_itr(), back_ins_itr(num));
    
// STL中的排序算法
    sort(num.begin(), num.end());
    
// 将排序结果输出到标准输出设备
    copy(num.begin(), num.end(), ostream_itr(cout, " "));

    cout
<<endl;
    
return 0;
}

Feedback

# re: 号称唯美主义的杰作  回复  更多评论   

2007-09-20 11:33 by BNJ
强。
STL也有如此用法
只有注册用户登录后才能发表评论。