#include <iostream>
#include <sstream>
#include <iterator>
#include <vector>

using namespace std;

int main()
{
    string sentence = "house tree car";
    
    cout << "original string: " << sentence;
    
    istringstream iss(sentence);
    vector<string> tokens;
    copy(istream_iterator<string>(iss),
         istream_iterator<string>(),
         back_inserter< vector<string> >(tokens));
    
    cout << "\n     new string: ";
    for (int i = tokens.size() - 1; i >= 0; i--)
    {
        cout << tokens[i] << ' ';
    }

    return 0;
}