#include "stdafx.h"
#include "iostream"
#include "vector"
#include "string"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string str;
vector<string>vec;
char a[1];
while (cin >> str)
{
a[0]=cin.get();
if (a[0] == '\n')
{
vec.push_back(str);
break;
}
else
{
vec.push_back(str);
}
}
for (int i = vec.size(); i>0; i--)
{
cout << vec[i - 1] << " ";
}
getchar();
getchar();
return 0;
}
转载于:https://my.oschina.net/u/1446208/blog/464887
本文介绍了一个简单的C++程序,该程序使用标准输入接收一系列字符串,并将这些字符串存储在一个vector容器中。当遇到换行符时结束输入并按逆序输出所有已接收的字符串。
247

被折叠的 条评论
为什么被折叠?



