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. 【CV】CVPR2015_A Discriminative CNN Video Representation for Event Detection

    A Discriminative CNN Video Representation for Event Detection Note here: it's a learning note on the ...

  2. linux内核分析第五次实验

    给MenuOS增加time和time-asm命令 上周是从用户态的观点来理解系统调用,这周从内核态出发研究系统调用,通过跟踪调试,首先把上周的两个命令加到MenuOS中: rm menu -rf 强制 ...

  3. Linux内核分析第四章 读书笔记

    Linux内核分析第四章 读书笔记 第一部分--进程调度 进程调度:操作系统规定下的进程选取模式 面临问题:多任务选择问题 多任务操作系统就是能同时并发地交互执行多个进程的操作系统,在单处理器机器上这 ...

  4. Linux内核分析 读书笔记 (第十八章)

    第十八章 调试 18.1 准备开始 1. 需要的只是: 一个bug 一个藏匿bug的内核版本 相关内核代码的知识和运气 2. 在跟踪bug的时候,掌握的信息越多越好. 18.2 内核中的bug 1.  ...

  5. 使用Junit进行单元测试

    使用Junit进行单元测试 一.目的和要求 JUnit是一款由Erich Gamma(<设计模式>的作者)和Kent Beck(极限编程的提出者)编写的开源的回归测试框架,供Java编码人 ...

  6. [cnblog新闻]历史性时刻:云硬件支出首次高于传统硬件

    https://news.cnblogs.com/n/617487/ 据调研公司 IDC 声称,2018 年第三季度云硬件支出占 IT 总收入的 50.9%. 知名调研公司 IDC 声称,面向云的 I ...

  7. [kali] 安装完kali之后允许远程ssh

    1. 安装kali 2.控制台登录kali 3. 修改 /etc/ssh/sshd_config 4.将 permitrootlogin 前面的注释去掉,并且后面改为yes 5.然后重启ssd服务 / ...

  8. Java之byte、char和String类型相互转换

    package basictype; /** * byte.char和String类型相互转换 */ public class CHJavaType { public static void main ...

  9. Omni(USDT)钱包安装(ubuntu)

    一.下载Omni Layer钱包 wget https://bintray.com/artifact/download/omni/OmniBinaries/omnicore-0.3.0-x86_64- ...

  10. /include/caffe/common.cuh(9): error: function "atomicAdd(double *, double)" has already been defined

    https://stackoverflow.com/questions/39274472/error-function-atomicadddouble-double-has-already-been- ...