Problem : (1.2.1) Text Reverse
来源:互联网 发布:ubuntu命令行复制文件 编辑:程序博客网 时间:2024/06/05 09:33
#include<iostream>using namespace std;void main(){char arr[1000];int a,n;int s,t;cin>>a;getchar();for(int i=0;i<a;i++){gets(arr);n=strlen(arr);s=0;for(int j=0;j<=n;j++){if(arr[j]==' '||arr[j]=='\0'){t=j;for(int l=t-1;l>=s;l--){cout<<arr[l];}s=t+1;if(s!=n+1)cout<<" ";}}cout<<endl;}}
Problem Description
Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single line with several words. There will be at most 1000 characters in a line.
Each test case contains a single line with several words. There will be at most 1000 characters in a line.
Output
For each test case, you should output the text which is processed.
Sample Input
3olleh !dlrowm'I morf .udhI ekil .mca
Sample Output
hello world!I'm from hdu.I like acm.<div style="" border-bottom:="" #b7cbff="" 1px="" dashed;="" border-left:="" padding-bottom:="" 6px;="" padding-left:="" padding-right:="" font-family:="" times"="">HintRemember to use getchar() to read '\n' after the interger T, then you may use gets() to read a line and process it.
0 0
- Problem : (1.2.1) Text Reverse
- Problem L-12 Reverse Text
- ZOJ Problem Set - 1295 Reverse Text
- ZOJ Problem Set - 1295 Reverse Text
- ZOJ Problem Set - 1295 Reverse Text
- HDU Text Reverse/1.2
- Reverse Text
- Reverse Text
- Reverse Text
- Text Reverse
- Reverse Text
- Text Reverse
- Text Reverse
- Reverse Text
- Text Reverse
- Text Reverse
- Reverse Text
- Text Reverse
- eclipse中使用git
- SurfaceHolder.Callback
- ArrayList 和 Vector 比较
- cocos2d-x中的模态对话框简单实现
- 自己写的strcpy函数 mystrcpy()------数组版
- Problem : (1.2.1) Text Reverse
- 高性能 CSS3 动画
- jQzoom 配置参数
- Android 接口等级与版本对照
- 浅谈网站优化的五个阶段
- java对cookie的操作
- PHP十天快速入门
- c++ 类的继承与派生
- .NET开发不可错过的25款必备工具