输入:
I am a student
输出:
student a am I
最简单的做法:
#include <iostream>
using namespace std;
int main()
{
string str,res;
while(cin >> str) res=str+' '+res;
cout << res;
return 0;
}
做法2:
#include <iostream>标签:cout,倒排,int,res,am,单词,str,namespace From: https://blog.51cto.com/u_15815053/5890409
using namespace std;
int main()
{
string str[201];
int n=0;
while(cin >> str[n]) n++;
for(int i=n-1;i>=0;i--) cout << str[i] << ' ';
return 0;
}