Skip to content

Latest commit

 

History

History
38 lines (36 loc) · 1.01 KB

File metadata and controls

38 lines (36 loc) · 1.01 KB
#include <iostream>
using std::cin; using std::cout; using std::endl; using std::cerr;
#include <fstream>
using std::ifstream;
#include <string>
using std::string;
#include <vector>
using std::vector;
#include <list>
using std::list;
#include <iterator>
using std::istream_iterator; using std::ostream_iterator;
using std::reverse_iterator;

int main() {
    string input_path("/home/raymain/CLionProjects/CPPLv1/test.txt");
    ifstream input(input_path);
    if (input.is_open()){
        istream_iterator<int> int_iter(input), eof;
        ostream_iterator<int> out(cout, " ");
        vector<int> vi(int_iter, eof);
        cout << "Now vector has these values: \n";
        for (auto const &a : vi)
            out = a;
        cout << endl;
        list<int> li((vi.rbegin() + 2), (vi.rend() - 3));
        cout << "Now list has these values: \n";
        for (auto const &a : li)
            out = a;
        cout << endl;
    } else {
        cerr << "Failed to open file" << endl;
        return EXIT_FAILURE;
    }
}