1. Enter a line of numbers or strings (unknown number), spaced by spaces, end the input and output after a new line
// 数字
unsigned int buf, index = 0;
vector<unsigned int> arr(1000000);
while (cin >> buf)
{
arr[index++] = buf;
char ch = getchar(); // 通过getchar()来判断最后输入回车符结束
if (ch == '\n')
break;
}
// 字符串
string str;
getchar(cin, str);
2. Initialize the vector
vector<unsigned int> arr(1000000, 0); // 初始化了 一百万 个值为0的vector数组;
Reference C++: Summary of initialization definition and assignment method of vector