Text Reverse

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12577    Accepted Submission(s): 4743

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.

 

Author
Ignatius.L
 
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
using namespace std;
char str[1000];
int main()
{
    int T;
    cin>>T;
    getchar();
while(T--)
{
    stack<char> st;
    gets(str);
    int len=strlen(str);
    int i;
    str[len]=' ';
    for(i=0;i<=len;i++)
    {
        if(str!=' ')
        {
           st.push(str);
        }
        else  if(str==' ')
        {
            while(!st.empty())
            {
                cout<<st.top();
                st.pop();
            }
            if(i!=len)
            cout<<" ";
            else
            cout<<endl;
        }
    }
}
    return 0;
}

HDOJ 1062 Text Reverse的更多相关文章

  1. hdu 1062 Text Reverse 字符串

    Text Reverse                                                                                  Time L ...

  2. HDOJ/HDU 1062 Text Reverse(字符串翻转~)

    Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...

  3. 【HDOJ】1062 Text Reverse

    Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignati ...

  4. 题解报告:hdu 1062 Text Reverse

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062 Problem Description Ignatius likes to write word ...

  5. HDU 1062 Text Reverse(水题,字符串处理)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062 解题报告:注意一行的末尾可能是空格,还有记得getchar()吃回车符. #include< ...

  6. 1062 Text Reverse

    http://acm.hdu.edu.cn/showproblem.php?pid=1062 思路: 最主要的是通过getline函数存取字符串. 如何读取单个单词,并且反向输出? 用\n作为单个单词 ...

  7. HDU 1062 Text Reverse

    题意 : 给出你一个句子,让你把句子中每个单词的字母顺序颠倒一下输出. 思路 : 用栈即可,就是注意原来在哪儿有空格就要输出空格. //hdu1062 #include <iostream> ...

  8. [hdu 1062] Text Reverse | STL-stack

    原题 题目大意: t组数据,每组为一行,遇到空格时讲前面的单词反转输出. 题解: 显然的栈题,遇到空格时将当前栈输出清空即可 #include<cstdio> #include<st ...

  9. 简单字符串处理 hdu1062 Text Reverse

    虽然这个题目一遍AC,但是心里还是忍不住骂了句shit! 花了一个小时,这个题目已经水到一定程度了,但是我却在反转这个操作上含糊不清,并且还是在采用了辅助数组的情况下,关系的理顺都如此之难. 其实我是 ...

随机推荐

  1. Toast提示信息

    用Toast来作为操作成功以及用户误操作等等的提示,非常的简单.直接上代码: 创建方式一: ps: 此处没有设置toast的其他属性,均使用默认的风格(个人觉得默认的风格除了字体比较小之外 还是挺好看 ...

  2. Ioc 控制反转 实例

    关于IOC 或者是DI 什么的真的很坑爹. 开始理解了这东西了然后闲的没事就又百度了一下,得  我又凌乱了.  看了两个大神的贴 尼玛啊 完全是反过来了. 纠结了半天.然后就想找个简单点不坑爹的原理代 ...

  3. Multi-Language IDE for Professional Developers (Komodo)

    Komodo is the professional IDE for major web languages, including Python, PHP, Ruby, Perl, HTML, CSS ...

  4. hdu1007

    Have you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some ...

  5. hdu 1008

    题目意思是:给你N个数字  每个数字表示多少层楼  现在要你从0层楼开始坐电梯  一次按顺序走过这些楼层 规则是 上楼6秒 ,下楼4秒,每次到达一个楼层停5秒..... 思路:模拟 代码如下:(要注意 ...

  6. Linux下安装宋体以及微软雅黑字体

    最近工作用itext生成pdf在windows环境下没有出现中文乱码而在linux下出现中文乱码,打开pdf查看pdf编码,以及显示的编码,发现编码并没有对应.原因是使用的宋体和微软雅黑在linux环 ...

  7. hdu 5444 Elven Postman

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5444 Elven Postman Description Elves are very peculia ...

  8. Windows下使用Visual Studio Code搭建Go语言环境

    1.安装GO语言   下载地址:    https://golang.org/dl/   Windows下直接运行安装GO语言即可.     安装成功.   安装完毕GO语言后,需要添加GOPATH环 ...

  9. [转]Ubuntu 12.04开机自动挂载Windows分区

    [转]Ubuntu 12.04开机自动挂载Windows分区 http://www.cnblogs.com/A-Song/archive/2013/02/27/2935255.html 系统版本:Ub ...

  10. Entity Framework 学习第二天 续

    今天来写一点不一样的删除,修改,查询 下面只写了几个方法 /// <summary> /// 根据删除条件进行删除 /// </summary> /// <param n ...