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

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
char a[];
int n;
scanf("%d",&n);
getchar();
while(n--)
{
gets(a);
int len=strlen(a);
int next[],m=;
for(int i=;i<=len;i++)
{
if(a[i]==' '||i==len)
{
for(int j=i-;j>=&&a[j]!=' ';j--)
{
next[m++]=j;
}
}
if(a[i]==' ')
{
next[m++]=i;
}
}
for(int i=;i<len;i++)
{
putchar(a[next[i]]);
}
printf("\n");
}
}
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.
         
 
 

CDZSC_2015寒假新人(1)——基础 g的更多相关文章

  1. CDZSC_2015寒假新人(2)——数学 G

    G - G Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  2. CDZSC_2015寒假新人(1)——基础 e

    Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever ...

  3. CDZSC_2015寒假新人(1)——基础 i

    Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you mus ...

  4. CDZSC_2015寒假新人(1)——基础 h

    Description Ignatius was born in a leap year, so he want to know when he could hold his birthday par ...

  5. CDZSC_2015寒假新人(1)——基础 f

    Description An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u i ...

  6. CDZSC_2015寒假新人(1)——基础 d

    Description These days, I am thinking about a question, how can I get a problem as easy as A+B? It i ...

  7. CDZSC_2015寒假新人(1)——基础 c

    Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the wareho ...

  8. CDZSC_2015寒假新人(1)——基础 b

    Description The highest building in our city has only one elevator. A request list is made up with N ...

  9. CDZSC_2015寒假新人(1)——基础 a

    Description Contest time again! How excited it is to see balloons floating around. But to tell you a ...

随机推荐

  1. 一个Restful Api的访问控制方法

    最近在做的两个项目,都需要使用Restful Api,接口的安全性和访问控制便成为一个问题,看了一下别家的API访问控制办法. 新浪的API访问控制使用的是AccessToken,有两种方式来使用该A ...

  2. 了不起的分支和循环02 - 零基础入门学习Python008

    了不起的分支和循环02 让编程改变世界 Change the world by program 上节课,小甲鱼教大家如何正确的打飞机,其要点就是:判断和循环,判断就是该是不该做某事,循环就是持续做某事 ...

  3. ftp二进制与ascii传输方式区别

    ASCII 和BINARY模式区别:    用HTML 和文本编写的文件必须用ASCII模式上传,用BINARY模式上传会破坏文件,导致文件执行出错.    BINARY模式用来传送可执行文件,压缩文 ...

  4. php读取文件的各种方法

    博客根据http://www.ibm.com/developerworks/cn/opensource/os-php-readfiles个人总结 获取文件全部内容 以下归类是按平时我们通常的使用方法总 ...

  5. BIN和HEX文件的区别

    HEX文件和BIN文件是我们经常碰到的2种文件格式.下面简单介绍一下这2种文件格式的区别: 1.HEX文件是包括地址信息的,而BIN文件格式只包括了数据本身.在烧写或下载HEX文件的时候,一般都不需要 ...

  6. 《Programming WPF》翻译 第8章 4.关键帧动画

    原文:<Programming WPF>翻译 第8章 4.关键帧动画 到目前为止,我们只看到简单的点到点的动画.我们使用了To和From属性或者By属性来设计动画--相对于当前的属性值.这 ...

  7. Powershell 快捷键

    Powershell的快捷键和cmd,linux中的shell,都比较像. ALT+F7 清除命令的历史记录PgUp PgDn 显示当前会话的第一个命令和最后一个命令Enter 执行当前命令End 将 ...

  8. Source insight添加工具自动排版

    当在网上找了一些别人的程序拿来学习,用Source insight来看时,会不会因为代码太乱看了义愤填膺呢? 有很多集成的开发环境可以自动排版,但source insight却不行!不过,有工具和配置 ...

  9. Palindrome Partitioning 解答

    Question Given a string s, partition s such that every substring of the partition is a palindrome. R ...

  10. 沙湖王 | 用K-均值聚类给女明星们的身材分分类

    沙湖王 | 用K-均值聚类给女明星们的身材分分类 http://www.shahuwang.com/2012/07/21/%E7%94%A8scipy%E5%AE%9E%E7%8E%B0k-means ...