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. mongo数据库备份与恢复

    备份:mongodump -h xx --port 27017 -u user -p pass -d database -o D:\backup\database 恢复:mongorestore -h ...

  2. CentOS 下安装apt-get

    CentOS 下安装apt-get 最近在学习Linux系统时,网上好多帖子都是用apt-get里下载rpm包,于是就在Google上找了个CentOS下安装apt-get的方法 1.下载地址:htt ...

  3. 【.NET】XML文件的创建,修改,删除

    类名:XML /// 1.创建XML文档 /// 2.在根节点下增加子元素 /// 3.在元素下增加子元素 /// 4.获取类型为制定值的一组节点 /// 5.抓取网页上的xml文档赋值给XmlDoc ...

  4. laravel php artisan migrate 数据迁移时出现的[HY000][1045]错误

    (zz找了块一个小时才发现)主要的错误在于.env文件和database.php的配置不匹配. 1.找到.env文件 2.更改数据库表账密 3.改database.php的数据库账密 4.完成

  5. LINQ To SQL 处理 DateTime?

    LINQ To SQL 处理 DateTime? 类型 例子: 搜索栏含有最后扫描时间的日期(DateTime?)与多个其他条件(String) 现在需要写一个查询 : 查询符合最后扫描的日期的查询 ...

  6. 关于并行计算的Scan操作

    simple and common parallel algorithm building block is the all-prefix-sums operation. In this chapte ...

  7. 关于linux修改max user processes limits的问题

    我们都知道,ulimit -u 可以设置max user processes limits,但是往往在设置的过程中,这样直接修改,不仅只能临时生效,重启之后又无效了,而且老是会失败. 而一般来说,修改 ...

  8. Idea1.5使用Maven搭建Apache Spark1.6源码阅读环境

    1.插件安装,在Idea界面依次:File->settings->plugins,安装Maven 2.下载Spark1.6.2源码,这个在GitHub上下载,具体流程自己百度,很简单 3. ...

  9. iosTableView 局部全部刷新以及删除编辑操作

    局部刷新方法 添加数据 NSArray *indexPaths = @[ [NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath index ...

  10. 大数据时代之hadoop(三):hadoop数据流(生命周期)

    了解hadoop,首先就需要先了解hadoop的数据流,就像了解servlet的生命周期似的.hadoop是一个分布式存储(hdfs)和分布式计算框架(mapreduce),但是hadoop也有一个很 ...