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. M1/M2项目阶段总结

    1.M1/M2总结 我们这学期完成了学霸项目. 在M1阶段,我们首先进行了分工,完成了一个系统的计划,然后是对学长代码的移植和优化.在优化代码的过程中,我们遇到了不少问题,比如一些代码的冗余以及指向性 ...

  2. Beta项目展示

    Team C# 一.团队成员简介 杜正远,队长. 博客地址:http://www.cnblogs.com/kevindu/ 崔强,全职PM. 博客地址:http://www.cnblogs.com/m ...

  3. 20135327郭皓--Linux内核分析第七周 可执行程序的装载

    第七周 可执行程序的装载 郭皓 原创作品转载请注明出处 <Linux内核分析>MOOC课程 http://mooc.study.163.com/course/USTC-1000029000 ...

  4. BugPhobia进阶篇章:前端技术/设计文档

    0x01 :前端概述 0x0100 :前端基本描述 前端基础框架 Semantic UI 根据http://semantic-ui.com/提供的样例和文档,依据Version 2.1.4版本的特性进 ...

  5. mybatis逆向工程生成example的问题

    如果不想生成example,在 targetRuntime="MyBatis3" 处修改为  targetRuntime="MyBatis3Simple"  & ...

  6. Axios插件和loading的实现

    axios插件就是一个ajax插件 axios具有ajax的所有方法如 get post delete put等等的方法 使用时只需要引入即可 如import Axios form 'axios' 不 ...

  7. React 模板

    <!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...

  8. PS(光影魔术手)

    完成

  9. Ionic package Error: Registry returned 404 for GET on

    Ionic package Error: Registry returned 404 for GET on https://registry.npmjs.org/org.apache.cordova. ...

  10. 编译安装openssl

    wget https://www.openssl.org/source/openssl-1.1.0g.tar.gztar xf openssl-1.1.0g.tar.gzcd openssl-1.1. ...