#include<iostream>
#include<sstream>
#include<string>
using namespace std;
void reverse(string *s,int length){
for(int i=0,j=length-1;i<=j;i++,j--){
string temp=s[i];
s[i]=s[j];
s[j]=temp;
}}
void main(){
string buf;
istringstream iss(str);
int i=0;
do
{
iss >> s[i++];
} while (iss);
reverse(s,i-1);
for(int j=0;j<i;j++){
cout<<s[j];
if(j<i-1) cout<<" ";
else cout<<endl;
}}
#include<sstream>
#include<string>
using namespace std;
void reverse(string *s,int length){
for(int i=0,j=length-1;i<=j;i++,j--){
string temp=s[i];
s[i]=s[j];
s[j]=temp;
}}
void main(){
string s[1000];
//将按空格分隔的单词提取出来,成为string数组
string str("hi baidu com mianshiti");string buf;
istringstream iss(str);
int i=0;
do
{
iss >> s[i++];
} while (iss);
reverse(s,i-1);
for(int j=0;j<i;j++){
cout<<s[j];
if(j<i-1) cout<<" ";
else cout<<endl;
}}