Problem : (1.2.1) Text Reverse
#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. |
Output
For each test case, you should output the text which is processed.
|
Sample Input
3 |
Sample Output
hello world! |
Problem : (1.2.1) Text Reverse的更多相关文章
- HDOJ 1062 Text Reverse
Text Reverse Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu 1062 Text Reverse 字符串
Text Reverse Time L ...
- Text Reverse
Text Reverse Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- (reverse) Text Reverse hdu1062
Text Reverse Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- 简单字符串处理 hdu1062 Text Reverse
虽然这个题目一遍AC,但是心里还是忍不住骂了句shit! 花了一个小时,这个题目已经水到一定程度了,但是我却在反转这个操作上含糊不清,并且还是在采用了辅助数组的情况下,关系的理顺都如此之难. 其实我是 ...
- HDOJ/HDU 1062 Text Reverse(字符串翻转~)
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...
- HDU1062:Text Reverse
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...
- 杭电acm刷题(3):1062,Text Reverse 标签: 杭电acm 2017-05-15 08:26 126人阅读 评论(0)
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...
- 题解报告:hdu 1062 Text Reverse
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062 Problem Description Ignatius likes to write word ...
随机推荐
- 重温基础之-css盒模型
所有html元素都可以看作盒子. css盒模型本质上是一个盒子,封装周围的html元素,它包括:外边距,边框,内边距和实际内容. 默认情况下,一个元素的总宽度计算方式: 总宽度=左外边距+左边框+左内 ...
- HDU - 2154 线性dp
思路:0表示A,1表示B,2表示C,d(i, j)表示在第j次时正好到达i. AC代码 #include <cstdio> #include <cmath> #include ...
- linux分析apache日志获取最多访问的前10个IP
apache日志分析可以获得很多有用的信息,现在来试试最基本的,获取最多访问的前10个IP地址及访问次数. 既然是统计,那么awk是必不可少的,好用而高效. 命令如下: awk '{a[$1] += ...
- ThinkPad W500 清灰记录
转载请注明出处:HateMath归来(http://www.cnblogs.com/hatemath/) 看型号就知道,这是一台英雄迟暮型的老电脑.到了夏天,启动后啥事不做,通风口都烫手.心情好,一时 ...
- SDP(9):MongoDB-Scala - data access and modeling
MongoDB是一种文件型数据库,对数据格式没有硬性要求,所以可以实现灵活多变的数据存储和读取.MongoDB又是一种分布式数据库,与传统关系数据库不同的是,分布式数据库不支持table-join,所 ...
- mysql数据库 调优
mysql调优硬件配置网络带宽mysql运行参数慢查询日志网络架构多实例(一台服务器上运行多个数据库服务)分库分表 当一台数据库服务器处理客户端的请求慢时,可能是哪些原因造成? 硬件配置低:(内存 c ...
- 前端日常常用git命令
讲真,很早之前就想总结一下git常用的命令了,每次用着用着很多命令都记不住.而且我是英语渣包,有些单词慢慢靠背. git只是一个工具,我这写的只是适合我这种快速上手使用工具的小白,深究的请移步别处. ...
- 1_Two Sum --LeetCode
原题如下: 思路:将nums放到一个map<int,int>中,其中,键是nums中元素,值对应其下标.然后遍历nums,取nums中一个值nums[i],接着用target减去它,最后再 ...
- Struts2实现文件上传报错(二)
1.具体报错如下 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -he ...
- (三十一)java多线程二
因为线程在执行的过程中具有一定的不确定性,在并发的时候就会出现安全问题,因此一般需要采取一定的措施来保证线程的安全,同步代码块就是其中一种方式. 以下是模拟银行取钱的多线程小例子,两个都能确保安全,但 ...