Text Reverse

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

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.

思路:字符串处理,注意细节,容易出错。

#include<stdio.h>
#include<string.h>
char str[],temp[],*p;
int
main()
{

int
n,i,j;
scanf("%d",&n);
getchar();
while
(n--)
{

memset(str,,sizeof(str));
gets(str);
p = str;
i =;
while
(*p!='\0')
{

if
(*p!=' ')
{

temp[i++] = *p;
if
(*(p+)==' ')
temp[] = ' ';
}

else

{

for
(j = i -;j >=;j --)
printf("%c",temp[j]);
i =;
}

if
(*(p+)=='\0')
{

for
(j = i -;j >;j --)
printf("%c",temp[j]);
}

p++;
}

printf("\n");
}

return
;
}

Text Reverse的更多相关文章

  1. HDOJ 1062 Text Reverse

    Text Reverse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  2. hdu 1062 Text Reverse 字符串

    Text Reverse                                                                                  Time L ...

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

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

  4. (reverse) Text Reverse hdu1062

    Text Reverse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tot ...

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

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

  6. HDU1062:Text Reverse

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

  7. Problem : (1.2.1) Text Reverse

    #include<iostream> using namespace std; void main() { char arr[1000]; int a,n; int s,t; cin> ...

  8. 杭电acm刷题(3):1062,Text Reverse 标签: 杭电acm 2017-05-15 08:26 126人阅读 评论(0)

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

  9. 题解报告:hdu 1062 Text Reverse

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

随机推荐

  1. 【笔记】mongodb启动不了:child process failed, exited with error number 100

    今天在启动mongodb的时候,发现起不来,报错:child process failed, exited with error number 100然后先去/var/log/mongo/mongod ...

  2. eclipse中定位引用的源码

    如图,在eclipse中,我想看BaseContoller是怎么实现的,将鼠标放上去,按住Ctrl单击左键就行了

  3. Poj 1511 Invitation Cards(spfa)

    Invitation Cards Time Limit: 8000MS Memory Limit: 262144K Total Submissions: 24460 Accepted: 8091 De ...

  4. tomcat内存溢出问题

    内存泄露java.lang.OutOfMemoryError: PermGen space解决办法 今天访问web服务器,tomcat服务就瘫痪了,通过查看日志,发现java.lang.OutOfMe ...

  5. problem 1 -- Two sum

    很简单.没什么好说的.但是在阿里实习的第四面的时候居然问到了. 大意是给出一组无序数列和目标数Z,在无序数列中找到X和Y,使得X+Y=Z. 有两种方法: 一种是排序后,同时首尾搜索.时间复杂度为O(n ...

  6. node.js操作mongoDB数据库

    链接数据库: var mongo=require("mongodb"); var host="localhost"; var port=mongo.Connec ...

  7. linux 下C语言编程库文件处理与Makefile编写

    做开发快3年了,在linux下编译安装软件算是家常便饭了.就拿gcc来说,都有不下10次了,可基本每次都会碰到些奇奇怪怪的问题.看来还是像vs.codeblocks这样的ide把人弄蠢了.便下定决心一 ...

  8. WPF中嵌入Flash(ActiveX)

    1. 建立 WPF Application. 首先,建立一个名为 FlashinWPF 的 WPF Application 2. 设置 Window 属性. 在 XAML 中修改 Window 的属性 ...

  9. nRF52系列——nRF52832来袭

    nRF52系列——nRF52832来袭 Nordic凭借着在无线技术的数十年深耕,推出第一个μBlue芯片-- nRF8001.其低功耗等特性在当时吸引了无数厂商的目光,并将这产品应用到多个领域,再之 ...

  10. POJ 3371 Flesch Reading Ease 无聊恶心模拟题

    题目:http://poj.org/problem?id=3371 无聊恶心题,还是不做的好,不但浪费时间而且学习英语. 不过为了做出点技术含量,写了个递归函数... 还有最后判断es,ed,le时只 ...