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. Objective-C:继承的体现

    典型的继承例子:形状Shape为基类,继承它的类有:点类Point.圆类Circle.球体类Sphere.矩形类Rectangle.正方形类Square 点类Point也为基类,继承它的类有:圆类Ci ...

  2. OpenCV学习(34) 点到轮廓的距离

    在OpenCV中,可以很方便的计算一个像素点到轮廓的距离,计算距离的函数为: double pointPolygonTest(InputArray contour, Point2f pt, bool ...

  3. Tomcat安装笔记(on Mac)

    1. 官网 http://tomcat.apache.org/ 下载apache包,我下的8.5 注意要下core包的tgz版本,我开始下了full doc. 2. 拷贝解压到 /Library, 然 ...

  4. 什么是'脑分裂(split brain)'?

    这个词明显有点恐怖.设想一下,如果某时刻连接两个控制器之间的通路出现了问题,而不是其中某个控制器死机,此时两个控制器其实都是工作正常的,但是两者都检测不到对方的存在,所以两者都尝试接管所有总线,这时候 ...

  5. Android硬件入门-照相机

    学习Android不能不学习照相机,现在各种美容相机,微信朋友圈发图,现在升级之后直接下拉就可以照相了,各种艳照的的源头也是照相机,扯远了,有点邪恶了,还是简单学习一下Android中照相机的使用,A ...

  6. RecyclerView 判断滑到底部 顶部 预加载 更多 分页 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  7. nginx配置解决vue单页面打包文件大,首次加载慢的问题

    cnpm run build 文件过大,其中主要是vender.js有1.5M,代码部署到服务器,首次访问加载页面时比较慢,耗时6.5s左右,所以需要优化下. 1.Nginx开启gzip 找到ngin ...

  8. Oracle根据字段值找到表名和列名

    方法1: --Oracle 根据字段值查询其所在的表.字段 DECLARE CURSOR cur_query IS SELECT table_name, column_name, data_type ...

  9. 如何利用SQL语句求日期的时间差值,并汇总网上的一些信息

    MySQL本身提供了 DATEDIFF 函数,用来计算时间差. 手册:http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.ht ...

  10. mysql时间操作函数和存储过程

    因为业务须要统计一批数据.用到关于mysql的时间操作函数和存储过程,问题已经基本解决.把过程记录下: 1. mysql的语句中不支持直接用循环.循环仅仅能在存储过程中使用. 2. 写为文件时,注意一 ...