c++ source code part 1

 

#include <iostream>
#include <fstream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main()
{
    ifstream in_file("a.txt");
    ofstream out_file("b.txt");

    if (!in_file || !out_file) {
        cout << "unable to open file" << endl;
        return -1;
    }

    istream_iterator<string> is(in_file);
    istream_iterator<string> eof;

    vector<string> text;
    copy(is, eof, back_inserter(text));

    sort(text.begin(), text.end());

    ostream_iterator<string> os(out_file, " ");
    copy(text.begin(), text.end(), os);
}

 

posted @ 2018-06-07 09:47  pfsi  阅读(115)  评论(0编辑  收藏  举报