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. 最近在学习UDP方面的通信,找到一个很棒的博客

    http://blog.csdn.net/kesalin/article/details/8798039

  2. java I/O技术

    一.流的分类 Java的流类大部分都是由InputStream.OutputStream.Reader和Writer这四个抽象类派生出来的 (1)按数据流向 输入流(InputStream类和Read ...

  3. IOS 学习笔记 2015-04-10 OC-常用常量

    一 常用常量 (I) 关于按钮 UIControlState--->按钮状态 A UIControlStateNormal 默认状态 常规状态显现 B UIControlStateHighlig ...

  4. MySQL簇-cluster

    http://www.php100.com/manual/MySQL/ndbcluster.html 先做个标记吧.

  5. Python学习笔记——正则表达式入门

    # 本文对正则知识不做详细解释,仅作入门级的正则知识目录. 正则表达式的强大早有耳闻,大一时参加一次选拔考试,题目就是用做个HTML解析器,正则的优势表现得淋漓尽致.题外话不多讲,直接上干货: 1. ...

  6. USB Key插入和移除监控

    近期在做USB Key插入和移除监控,已经做到了插入和移除USB Key时,程序能够及时感应到. 如下为源代码: private void Form1_Load(object sender, Even ...

  7. POJ 1459 Power Network 最大流(Edmonds_Karp算法)

    题目链接: http://poj.org/problem?id=1459 因为发电站有多个,所以需要一个超级源点,消费者有多个,需要一个超级汇点,这样超级源点到发电站的权值就是发电站的容量,也就是题目 ...

  8. 用powerdesigner建模工具生成数据库

    1,使用powerdesignerP:主键 F:外键 M:是否可为空 2,两张表建立主外键关系时,主外键名称要相同.比如A表 A_id name  说明id(P) B表 B_id name  说明id ...

  9. AirPlay简介

    AirPlay是苹果公司在iOS4.2即Mac OS Mountain Lion中加入的一种播放技术.可以将iPhone.iPod.iPad和Mac上的视频镜像传送到支持AirPlay的设备上(如音响 ...

  10. leetcode第六题 ZigZag Conversion (java)

    ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag pattern on a given nu ...