Skip to content

Latest commit

 

History

History
31 lines (29 loc) · 795 Bytes

File metadata and controls

31 lines (29 loc) · 795 Bytes
#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 <iterator>
using std::istream_iterator; using std::ostream_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);
        auto iter = vi.cend();
        do {
            --iter;
            out = *iter;
        } while (iter != vi.cbegin());
    } else {
        cerr << "Failed to open file" << endl;
        return EXIT_FAILURE;
    }
}