#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; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter