编写一段程序,用cin读入一组字符串并把它们存入一个vector对象
string word;
vector<string> text; // 空vector对象
while (cin >> word)
{
text.push_back(word); // 把word添加到text后面
}
cout << "vector添加元素后为:" << endl;
for (int i = 0; i < text.size(); i++)
{
cout << text[i] << " ";
}
cout << endl;