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
olleh !dlrow
m'I morf .udh
I ekil .mca
 
Sample Output
hello world!
I'm from hdu.
I like acm.

Hint

Remember to use getchar() to read '\n' after the interger T, then you may use gets() to read a line and process it.

 
#include <iostream>
#include <stdio.h>
#include <string.h> using namespace std; int main()
{
int n,i,k1,k2;
char data[];
cin>>n;
getchar();
while(n--)
{
k1=;k2=;
gets(data);
for(i=;i<=strlen(data);i++)
{
if(data[i]==' '||data[i]=='\0')//找空格,为了找单词
{
k2=i-;//是空格前面那个词的下标
for(k2;k2>=k1;k2--)//从K2一直打到k1这个词
cout<<data[k2];
k1=i+;//k1是下一个单词的开头的下标
if(data[i]==' ')
cout<<" ";
if(data[i]=='\0')
cout<<endl;
}
} }
return ;
}

HDU1062:Text Reverse的更多相关文章

  1. 简单字符串处理 hdu1062 Text Reverse

    虽然这个题目一遍AC,但是心里还是忍不住骂了句shit! 花了一个小时,这个题目已经水到一定程度了,但是我却在反转这个操作上含糊不清,并且还是在采用了辅助数组的情况下,关系的理顺都如此之难. 其实我是 ...

  2. (reverse) Text Reverse hdu1062

    Text Reverse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tot ...

  3. HDOJ 1062 Text Reverse

    Text Reverse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  4. hdu 1062 Text Reverse 字符串

    Text Reverse                                                                                  Time L ...

  5. Text Reverse

    Text Reverse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  6. Text Reverse(hdu1062)

    输入方式:先输入整数,再循环输入字符串. 思考:字符串中有空格.那么要在字符串大循环输入前,首先,用"getchar()"函数读取scanf_s()函数缓冲区的空格或者空行或者换行 ...

  7. HDOJ/HDU 1062 Text Reverse(字符串翻转~)

    Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...

  8. Problem : (1.2.1) Text Reverse

    #include<iostream> using namespace std; void main() { char arr[1000]; int a,n; int s,t; cin> ...

  9. 杭电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 ...

随机推荐

  1. 小白学C++的小问题

    昨天开始学习C++,使用的visual studio 2012. 1命名要有意义,避免用a,b,c,尽量使用num,result等让人看见就能明白相关含义的名字 2要有一定的注释,注释和有意义的命名可 ...

  2. .net中读取xml文件中节点的所有属性信息

    功能描述: 将数据以xml的格式记录成配置文件,需要获取配置文件中的数据时,则获取对应的配置文件,读取配置文件里对应节点的所有属性. 逻辑实现: 1.将数据配置好在xml文件中. 2.获取xml文件中 ...

  3. mis 系统的开发具备的条件

    MIS的开发方式有自行开发.委托开发.联合开发.购买现成软件包进行二次开发几种形式.一般来说根据企业的技术力量.资源及外部环境而定. 补充: 管理信息系统的开发策略不可行的开发方法:组织结构法,机械的 ...

  4. maven创建spring项目之后,启动报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoade

    错误: org.apache.catalina.core.StandardContext listenerStart严重: Error configuring application listener ...

  5. Generating Faces with Deconvolution Networks

    用深度学习做人脸合成,website:https://zo7.github.io/blog/2016/09/25/generating-faces.html 受启发于 Learning to Gene ...

  6. Java中泛型 类型擦除

    转自:Java中泛型是类型擦除的 Java 泛型(Generic)的引入加强了参数类型的安全性,减少了类型的转换,但有一点需要注意:Java 的泛型在编译器有效,在运行期被删除,也就是说所有泛型参数类 ...

  7. visual studio2013 改变匹配括号的颜色

    改变匹配括号的颜色实现如下效果

  8. bzoj4318: OSU!&&CF235BLet's Play Osu!

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=4318 4318: OSU! Time Limit: 2 Sec  Memory Limit ...

  9. HDU 1240 Asteroids!(BFS)

    题目链接 Problem Description You're in space.You want to get home.There are asteroids.You don't want to ...

  10. Ubuntu环境变量——系统变量和用户变量

    系统变量: 对所有用户有效果 /etc/profile /etc/environment 两个命令只用一个就可以,原则上是重启后修改生效,但是经过验证可以通过执行以下命令实现: source /etc ...