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. Qt将表格table保存为excel(odbc方式)

    首先是保存excel的方法,可参照: http://dzmlmszp.blog.163.com/blog/static/179271962014819111812531/ ok,进入正题. 现在我有一 ...

  2. C++内存对象布局

    本章主要介绍了c++类中成员变量.函数对象的在内存中布局. 当c++类中不包含virtual机制类的函数时,内部nostatic member被包含在每一个class object之中,就想c str ...

  3. c++模板编程-typename与class关键字的区别

    最近一直在研究c++模板编程,虽然有些困难,但希望能够坚持下去.今天,在书上看见一个讨论模板编程typename与class两个关键字的区别,觉得挺有意义的,就把它们给总结一下. 先看一个例子: te ...

  4. Java菜鸟学习笔记--面向对象篇(十五):Wrapper Class包装类

    什么是包装类? 在Java里一切都是对象,除了Java中的基本数据类型(byte,short,int,long,char,float,double,boolean)不是面向对象的,这在实际使用时存在很 ...

  5. android中细节效果总结

    android中细节效果总结   andorid取消最上方的标题同时全屏显示 Source code     protected void onCreate(Bundle savedInstanceS ...

  6. 数据画图 jpgraph & chart.js

    今天想到要研究下“用图表的形式来呈现数据”这个主题.对比了下两种实现的方法: 方法一:通过php代码在服务器端生成图像,再将图像传回客户端.使用jpGraph类库. 方法二:通过js和html5技术, ...

  7. CSS: Table-Layout & Word-Break 设置表和列的宽度固定不变

    1. 设置Table的列宽由表格宽度和列宽度设定(指定表格宽度,各个列宽度): table#tbl_id{table-layout:fixed;} 2. 设置TD内容根据宽度进行换行,即使字符串之间无 ...

  8. python保留指定文件、删除目录其他文件的功能(1)

    由于给客户的发布版本上客户改动了些代码和图片,我们这边给他们更新publish都是增量更新(开发提供更新指定的文件,我们提取出来给客户进行覆盖更新),但有时需要更新的文件较多导致不得不一个一个的进行查 ...

  9. openFileDialog与saveFileDialog的使用

    private void btnOpen_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogR ...

  10. Android-PullToRefresh 使用心得

    目前下拉刷新已经满大街都是,在自己的应用如果不使用这个模式的话,出门都不好意思和人家打招呼,该文章就是简单探讨下针对于 github 上的这个开源项目的使用心得. 为什么是它?因为在 stackove ...