求一字符串中子串逆转输出的算法!该如何处理

求一字符串中子串逆转输出的算法!
现有一字符串   str   =   "I   am   a   student! ";
要求输出的结果为:   student   a   am   I

现求一算法来实现此功能,在线等,多谢~

------解决方案--------------------
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <sstream>
using namespace std;


int main(int argc, char* argv[])
{
stringstream str;
str < < "I am a student ";
vector <string> v;
string xx;
while(str> > xx)
v.push_back(xx);
copy(v.rbegin(),v.rend(),ostream_iterator <string> (cout, " "));
return 0;
}
------解决方案--------------------
一个不错的算法,, 先逆转整个字符串,再分别逆转每个单词
------解决方案--------------------
参考了一下二楼的成果,改了一下:
stringstream str;
str < < "I am a student ";
list <string> Ls;
copy(istream_iterator <string> (str),istream_iterator <string> (),front_inserter(Ls));
copy(Ls.begin(),Ls.end(),ostream_iterator <string> (cout, " "));

------解决方案--------------------
如果只是输出
#include <stdio.h>
#include <string.h>

int main(void)
{
char str[20] = {0};
int n;

strxfrm(str, "I am a student ", sizeof(str));

n = strlen(str);
while(n--)
{
if (str[n] == ' ')
{
str[n] = '\0 ';
printf( "%s ", str + n + 1);
}
}
printf(str);

return 0;
}