#include <iostream>
#include <iterator>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
auto input = [](const string& msg)
{
cout << msg;
size_t i = 0;
cin >> i;
return [i](istream& is){
vector<int> v;
copy_n(istream_iterator<int>{is}, i, back_inserter(v));
return v;
};
};
int main()
{
auto v = input("Enter number of numbers, I'm lazy: ");
auto values = v(cin);
}
#include <iostream>
#include <iterator>
#include <algorithm>
#include <cctype>
using namespace std;
int main()
{
const size_t sz = 100;
int a[sz]{0};
cout << "Enter numbers: " << endl;
size_t cnt = 0;
while(cin)
{
char c = static_cast<char>(cin.get());
if(isdigit(c) || c == '-' || c == '+')
{
if(cnt < sz - 1)
{
int i = 0;
cin.putback(c);
cin >> i;
a[cnt++] = i;
}
else
{
cout << "Out of range: " << sz << endl;
break;
}
}
else if(c == ' ')
{
continue;
}
else
{
cout << "End or not number" << endl;
break;
}
}
copy_n(a, cnt, ostream_iterator<int>(cout, " "));
}