字符串-07. 说反话-加强版 (20)
字符串-07. 说反话-加强版 (20)
时间限制
200 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
陈越(浙江大学)
给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。
输入格式:测试输入包含一个测试用例,在一行内给出总长度不超过500 000的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用若干个空格分开。
输出格式:每个测试用例的输出占一行,输出倒序后的句子,并且保证单词间只有1个空格。
输入样例:Hello World Here I Come输出样例:
Come I Here World Hello
#include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> using namespace std; string temp,str[500000+2]; int main() { int cnt=0; while(cin>>temp) { str[cnt++]=temp; } for(int i=cnt-1;i>=0;i--) { if(i==cnt-1) cout<<str[i]; else cout<<' '<<str[i]; } cout<<endl; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
posted on 2015-07-28 11:43 Tob__yuhong 阅读(228) 评论(0) 编辑 收藏 举报