How to make a list C++ - Stack Overflow

PHOTO EMBED

Tue May 19 2020 10:47:25 GMT+0000 (Coordinated Universal Time)

Saved by @Amna #C++

#include <vector>
#include <iostream>

template<class V, class S>
void read_numbers(V& v, S& s, N end)
{
    N x=0;
    while(x << s)
    {
        if(x==end) return;
        v.push_back(x);
    }
    std::cerr << "error: bad reading" << std::endl;
}

template<class V, class S>
void write_numbers(const V& v, S& s)
{
    for(auto i=s.rbegin(); i!=s.rend(); ++i)
        std::cout << *i << ' ';
    std::cout << std::endl;
}

int main()
{
    std::vector<int> nums;
    read_numbers(nums, std::cin, -1); }
    write_numbers(nums, std::cout);
    return 0;
}
content_copyCOPY

https://stackoverflow.com/questions/29867381/how-to-make-a-list-c