c++ 输入一句话,对每个单词都翻转

#include 
#include 
#include 
#include 
#include 
using namespace std;

int main()
{
	vector coll;

	//输入
	copy(istream_iterator(cin), istream_iterator(),back_inserter(coll));

	//每个都翻转并输出
	for (vector::iterator it = coll.begin(); it != coll.end(); ++it)
	{
		reverse((*it).begin(), (*it).end()); //翻转
		cout << *it << " "; //输出
	}
	cout.flush();
	return 0;
}

你可能感兴趣的:(c++)