求帮助,为什么第一位一输不进vector容器中呢
#include<vector>
#include<functional>
#include<iterator>
using namespace std;
using std::string;
using std::vector;
using namespace placeholders;
int main()
{
int x;
cin >> x;
istream_iterator<int>in(cin),end;
vector<int>vec(in, end);
cout << vec.size() << endl;
for (auto ele : vec)
cout << ele << " ";
}
输入
1
2
3
4
5
ctrl^z
输出的是
2 3 4 5
解决方案
40
第一个int输入给了x, 后面的int输入才给了vec, 所以vec.size()比全部int输入个数少1