HDUOJ--------Text Reverse
Text ReverseTime 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的更多相关文章
- HDOJ 1062 Text Reverse
Text Reverse Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu 1062 Text Reverse 字符串
Text Reverse Time L ...
- Text Reverse
Text Reverse Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- 简单字符串处理 hdu1062 Text Reverse
虽然这个题目一遍AC,但是心里还是忍不住骂了句shit! 花了一个小时,这个题目已经水到一定程度了,但是我却在反转这个操作上含糊不清,并且还是在采用了辅助数组的情况下,关系的理顺都如此之难. 其实我是 ...
- (reverse) Text Reverse hdu1062
Text Reverse Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- HDOJ/HDU 1062 Text Reverse(字符串翻转~)
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...
- HDU1062:Text Reverse
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...
- Problem : (1.2.1) Text Reverse
#include<iostream> using namespace std; void main() { char arr[1000]; int a,n; int s,t; cin> ...
- 杭电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 ...
- 题解报告:hdu 1062 Text Reverse
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062 Problem Description Ignatius likes to write word ...
随机推荐
- Android之从Browser中打开本地的应用程序&微信检测是否有对应app
在对应的应用程序的AndroidManifest.xml中配置: <activity android:name=".ui.TabHostActivity" android:w ...
- C++ 转型动作 尽量避免 以及 那些意想不到的威胁
看完EffectiveC++的关于转型的章节,顿时认为周围的代码都处在悬崖边上~~ C的旧式转型:inta = 10; double b = (double)a; 对于C++的四种转型函数, cons ...
- 日期时间篇asctime ctime gettimeofday gmtime localtime mktime settimeofday time
asctime(将时间和日期以字符串格式表示) 相关函数 time,ctime,gmtime,localtime 表头文件 #include<time.h> 定义函数 char * asc ...
- 垃圾收集(GC)中如何确定哪些内存是"垃圾
垃圾收集(Garbage Collection,GC),要设计一个GC,需要考虑解决下面三件事情:(1)哪些内存需要回收?(2)什么时候回收?(3)如何回收? 哪些内存需要回收?根据<Java内 ...
- 第三章 mybatis-generator + mysql/ptsql
用了mybatis-generator,我就不再想用注解了,这与我之前说的注解与XML并用是矛盾的,知识嘛,本来就是多元化的,今天喜欢这个,明天喜欢那个,哈哈,看了mybatis-generator下 ...
- asp.net中使用ueditor 1.3.6上传图片问题
在asp.net中使用ueditor 1.3.6版本上传图片时,出现上传成功但是,图片无法正常显示的问题,解决方法如下: 只需要将imageUp.ashx中的info = up.upFile(cont ...
- AngularJS driective 封装 自动滚动插件
1.ui-smooth-scroll.js文件内容 angular.module('app') .directive('uiSmoothScroll', ['$location', '$anchorS ...
- SQL基础(二):SQL命令
1.SQL SELECT TOP 子句 SELECT TOP 子句用于规定要返回的记录的数目.SELECT TOP 子句对于拥有数千条记录的大型表来说,是非常有用的(或者比如选取某个最新的数据:我们可 ...
- Java基础(一):简介
一.java基础语法: 一个Java程序可以认为是一系列对象的集合,而这些对象通过调用彼此的方法来协同工作.下面简要介绍下类.对象.方法和实例变量的概念. 对象:对象是类的一个实例,有状态和行为.例如 ...
- C++11 lambda 表达式解析
C++11 新增了很多特性,lambda 表达式是其中之一,如果你想了解的 C++11 完整特性,建议去这里,这里,这里,还有这里看看.本文作为 5 月的最后一篇博客,将介绍 C++11 的 lamb ...