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. javascript BOM对象 第15节

    <html> <head> <title>浏览器对象</title> <script type="text/javascript&quo ...

  2. Lua数组排序

    代码 network = { {name = "grauna", IP = "210.26.30.34"}, {name = "arraial&quo ...

  3. vs的watch使用

    VC调试器高级应用----WATCH窗口篇 一.格式化数据和表达式赋值语句. 常用变量格式化符(表达式的值后跟逗号,接格式化符,如"(int)0xFFFF,d"):d  :有符号的 ...

  4. UITextAlignmentCenter' is deprecated: first deprecated in iOS 6.0

  5. mac 下 sublime text 运行c++/c 不能使用scanf/cin

    { "cmd": ["g++", "${file}", "-o", "${file_path}/${file_ ...

  6. C# 调用 MFC DLL

    创建项目 创建MFCDLL项目 MFC项目中这么声明 生成dll工程 可以看到库文件的生成目录,保存下来 创建测试用c#项目 我们创建一个按钮调用我们刚才的函数 这边这么调用MFC库的函数入口.这里并 ...

  7. Linq表连接大全(INNER JOIN、LEFT OUTER JOIN、RIGHT OUTER JOIN、FULL OUTER JOIN、CROSS JOIN)

    我们知道在SQL中一共有五种JOIN操作:INNER JOIN.LEFT OUTER JOIN.RIGHT OUTER JOIN.FULL OUTER JOIN.CROSS JOIN 1>先创建 ...

  8. sql日期函数

    1.sql常用日期函数 当我们在进行数据处理的时候,常常需要用到日期函数的计算,最难的任务恐怕是确保所插入的日期的格式,与数据库中日期列的格式相匹配.只要数据包含的只是日期部分,运行查询就不会出问题. ...

  9. php验证复选框有效性的示例

    本文介绍一个简单的php通过代码验证复选框值的有效性,有需要的可以参考一下 验证复选框的php代码,如下: 复制代码代码如下: <?php   /**   * 在php中验证复选框的有效性  * ...

  10. html中th 与thead tbody的 使用

    上午工作的时候,遇到一挺纠结的问题,在<th width...> width根本不起作用. 后来才明白<th>标签不能写在<tbody>里,不符合语法. 所以顺便总 ...