Text Reverse

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 35208    Accepted Submission(s): 13824

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 <cstring>
#include <algorithm>
using namespace std;
int main()
{
int n;
char a[];
cin>>n;
getchar(); //别忘了要输入。
while(n--)
{
gets(a);
int len = strlen(a);
int s=,e=;
for(int i=;i<len;i++)
{
if(a[i]==' ')
{
e = i;
reverse(a+s,a+e); //对于C语言的字符串表示方式使用,但是对于string并不适用。
s=e+;
}
}
if(a[len-]!=' ') //要考虑每行的字符串的最后一个字符是否为空格。
{
e = len;
reverse(a+s,a+e);
}
printf("%s\n",a);
}
return ;
}

(reverse) Text Reverse hdu1062的更多相关文章

  1. HD-ACM算法专攻系列(7)——Text Reverse

    问题描述: 源码: /**/ #include"iostream" #include"string" using namespace std; void Pri ...

  2. LeetCode(68) Text Justification

    题目 Given an array of words and a length L, format the text such that each line has exactly L charact ...

  3. Javascript高级编程学习笔记(38)—— DOM(4)Text

    Text类型 html页面中的纯文本内容就属于Text类型 纯文本内容可以包含转义后的html字符,但不能包括 html 代码 text类型具有以下属性.方法 nodeType:3 nodeName: ...

  4. React Native组件(三)Text组件解析

    相关文章 React Native探索系列 React Native组件系列 前言 此前介绍了最基本的View组件,接下来就是最常用的Text组件,对于Text组件的一些常用属性,这篇文章会给出简单的 ...

  5. SHELL/VIM删除重复行(去重)text handle

    vim 删除重复行 - 国内版 Binghttps://cn.bing.com/search?FORM=U227DF&PC=U227&q=vim+%E5%88%A0%E9%99%A4% ...

  6. 文件名后面加(1).text

    ; //在重复名称后加(序号) while (File.Exists(path)) { if (path.Contains(").")) { int start = path.La ...

  7. (转)EntityFrameword “Reverse Engineer Code First” 连接 MySql

    转自:http://stackoverflow.com/questions/19676624/error-trying-to-reverse-engineer-code-first-mysql-dat ...

  8. LeetCode(150) Evaluate Reverse Polish Notation

    题目 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, ...

  9. leetcode解题报告(27):Reverse Linked List

    描述 Reverse a singly linked list. 分析 一开始写的时候总感觉没抓到要点,然后想起上数据结构课的教材上有这道题,翻开书一看完就回忆起来了,感觉解法挺巧妙的,不比讨论区的答 ...

随机推荐

  1. Python-str-操作-6

    #字符串的索引与切片 s = 'ABCDLSESRF' #索引 s1 = s[0] print(s1) s2 = s[2] print(s2) s3 = s[-1] print(s3) s4 = s[ ...

  2. 'config.h' file not found 解决过程

    最近将ReactNative业务集成进现有APP项目中,出现了几个具有代表性的问题,下面记录一下 问题1. [!] CocoaPods could not find compatible versio ...

  3. box-flex 弹性合布局+WebApp布局自适应

    问:随着屏幕改变,中间自适应 两边固定宽度? 参考: nec 布局 四种方法--博客园 问:左侧导航栏隐藏后,右侧内容宽度自动(响应式)变大? <!DOCTYPE html> <ht ...

  4. E. Train Hard, Win Easy

    链接 [http://codeforces.com/contest/1043/problem/E] 题意 有n个人,每个人都有做出a,b题的分数,xi,yi,但是有些人是不能组队的,问你每个人和其他能 ...

  5. 实验二 合作:王宏财 http://www.cnblogs.com/wanghongcai/

    package 四则运算; import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JOptionPane; ...

  6. Quartz.NET 入门,带C#实例

    概述 Quartz.NET是一个开源的作业调度框架,非常适合在平时的工作中,定时轮询数据库同步,定时邮件通知,定时处理数据等. Quartz.NET允许开发人员根据时间间隔(或天)来调度作业.它实现了 ...

  7. Java的Spring内实现的mini版内存"计数器"功能

    工期紧急,不让用Redis,自己实现了一个Spring内的mini版内存"计数器"功能,很简陋,和业务耦合太紧密,需要改进. public Long getCreationCoun ...

  8. jquery的extend方法(源码解析)

    1.前段时间一直忙于研究数据可视化(d3.js,three.js) 以及 php的 laravel框架,生活上也遇到很多事情,这大概就是人生中的迷茫期吧. 回想起,刚出来工作的时候,目标很明确,要学习 ...

  9. PHP常用工具类积累

    第一 请求第三方接口的工具类 例如,封装了get和post请求方法的工具类,代码如下: <?php class HttpClient{ /** * HttpClient * @param arr ...

  10. BZOJ3505 CQOI2014数三角形(组合数学)

    显然可以用总方案数减掉三点共线的情况.对于三点共线,一个暴力的做法是枚举起点终点,其间整点数量即为横纵坐标差的gcd-1.这样显然会T,注意到起点终点所形成的线段在哪个位置是没有区别的,于是枚举线段算 ...