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. Linux修改SSH端口和禁止Root远程登陆

    Linux修改ssh端口22 vi /etc/ssh/ssh_config vi /etc/ssh/sshd_config 然后修改为port 8888 以root身份service sshd res ...

  2. Android中使用OKHttp上传图片,从相机和相册中获取图片并剪切

    效果:注意:1:网络权限<;;;); intent.putExtra(); ); intent.putExtra(); intent.putExtra(, byteArrayOutputStre ...

  3. HTTP中的重定向和请求转发的区别

    原文出处:http://blog.csdn.net/meiyalei/article/details/2129120 一.调用方式 我们知道,在servlet中调用转发.重定向的语句如下: reque ...

  4. CSS三大样式

  5. NewtonJson中转义的斜杠\和多余的引号处理

    使用newtonjson序列化的json串正常的,但通过网络传输后,会再包装一层引号和对原有定义引号的转义,最后结果就变成这种数据: “\"{\\\"State\":fa ...

  6. php中的curl常用例子

    1.基本请求 <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.baidu.com"); ...

  7. java 守护线程

    守护线程生命周期: 守护线程是运行在后台的一种特殊线程, 它独立于控制终端并且周期性地执行某种任务或者等待处理某些发生的事件. 也就是说守护线程不依赖于终端,但是依赖于系统,与系统“同生共死”. 当J ...

  8. C# 委托的应用1:将方法作为参数传递给另一个方法[转]

    原文:http://blog.csdn.net/susan19890313/article/details/6775461 长期以来,c和c++的程序员利用方法指针,将方法作为参数传给另一个方法.c# ...

  9. .net webapi项目中支持session

    webapi中默认是不支持session的开启的 需要在Global.asax文件中,添加如下代码 public override void Init() { this.PostAuthenticat ...

  10. jq获取上级、同级、下级元素

    下面介绍JQUERY的父,子,兄弟节点查找方法 jQuery.parent(expr) 找父亲节点,可以传入expr进行过滤,比如$("span").parent()或者$(&qu ...