Text Reverse

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

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.

基础题:

代码:

 #include<iostream>
#define maxn 1005
using namespace std;
char str[maxn][maxn];
int main()
{
int n,i,cnt,j;
char c;
bool ifhave;
//freopen("test.in","r",stdin);
//freopen("teset.out","w",stdout);
scanf("%d",&n);
getchar();
while(n--)
{
j=i=;
ifhave=false;
while(c=getchar(),c!='\n')
{
if(c==' ')
j++,i=;
else
str[j][i++]=c; }
if(c==' ')
ifhave=true,j--;
cnt=j;
for(j=;j<=cnt;j++)
{
for(i=strlen(str[j])-; i>= ; i--)
printf("%c",str[j][i]);
if(j!=cnt) printf(" ");
}
if(ifhave)printf(" ");
puts("");
memset(str,'\0',sizeof str);
}
return ;
}

比较高级的代码:

 #include<stdio.h>
#include<string.h>
int main()
{
int t;
scanf("%d\n",&t);
while(t--)
{
char s[]={};
while(scanf("%[^ \n]",s)!=EOF)
{
printf("%s",strrev(s));
s[]=;
putchar(getchar());
}
}
return ;
}

HDUOJ--------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. Text Reverse

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

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

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

  5. (reverse) Text Reverse hdu1062

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

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

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

  7. HDU1062:Text Reverse

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

  8. Problem : (1.2.1) Text Reverse

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

  9. 杭电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 ...

  10. 题解报告:hdu 1062 Text Reverse

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

随机推荐

  1. founder面试题

    .写出正面程序支行结果: #include<iostream> using namespace std; void func(int a) { static int c = a; c++; ...

  2. maven生命周期(lifecycle)—— maven权威指南学习笔记(四)

    定义: 生命周期是包含在一个项目构建中的一系列有序的阶段 举个例子来说就是maven 对一个工程进行: 验证(validate) …… 编译源码(compile) …… 编译测试源码(test-com ...

  3. there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    建表语句: create table test_table(   id integer not null auto_increment primary key,   stamp_created tim ...

  4. IE11与Cognos怪谈

    想必大家都知道高版本的IE运行Cognos相关组件的时候要设置兼容性,安全级别相对调低等设置.但是升级了win10系统后,默认的IE版本是IE11的,装了Cognos10.2.1之后,进行了一个常规的 ...

  5. SqlServer2008安装时系统配置检查器重新启动计算机失败

    系统:win7 64 旗舰版   软件版本:sqlserver 2008 在安装前执行:系统配置检查器 的时候报错 ‘重新启动计算机失败’,如下图 处理办法: RebootRequiredCheck ...

  6. [Node.js] Child Process with fork() to handle heavy calculation process

    When build server, if we have a API endpoint requires some heavy calculation process, it will block ...

  7. [Backbone]1. Module, View classed

    Welcome to the Anatomy of Backbone.js challenges! We're going to be building a simple Appointment ap ...

  8. 运维-JVM监控之内存泄漏

    转载:https://blog.csdn.net/zdx_csdn/article/details/71214219 jmap -heap pid查看进程堆内存使用情况,包括使用的GC算法.堆配置参数 ...

  9. (剑指Offer)面试题61:按之字形顺序打印二叉树

    题目: 请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打印,第三行按照从左到右的顺序打印,其他行以此类推. 思路: 按照广度优先遍历来遍历二叉树,但是需要 ...

  10. OSX:不同OSX版本号的标记可能不兼容-续

    不同OSX版本号的标记可能不兼容-续: 经过測试,10.10DP2的Update.俗称DP3.的版本号也没有纠正这个问题.而造成该问题的是安装过程中一開始就选择中文,假设安装时使用英文.在第一次进入操 ...