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 ...
随机推荐
- Rational Rose、PowerDesign、Visio的一些比较
就目前建模软件来说,Rational Rose.PowerDesign.Visio三个是比较常用的系列了,在这里对它们做一些比较,我只用过PowerDesign.Visio和一个跟Rose很像的免费工 ...
- Java学习之路(转)
我也搞了几年JAVA了.因为一向懒惰,没有成为大牛,仅仅是一普通程序员,不爱玩社交站点.不爱玩微博,只有喜欢百度贴吧,潜水非常久了,手痒来给新人分享下从新手成长为老鸟的已见,也刷刷存在感,应该不比曝照 ...
- HBase性能调优(转)
原文链接:http://www.blogjava.net/ivanwan/archive/2011/06/15/352350.html 因官方Book Performance Tuning部分章节没有 ...
- FLume监控文件夹,将数据发送给Kafka以及HDFS的配置文件详解
详细配置文件flume-conf.properties如下: ############################################ # producer config ###### ...
- Python在Windows下操作CH341DLL
#! /usr/bin/env python #coding=utf-8 import os import time from ctypes import * class USBI2C(): ch34 ...
- js 获取读取cookie
// --- 设置cookie function setCookie(sName, sValue, expireHours) { var cookieString = sName + &quo ...
- 2015年末分享:利用RS修改用户密码
马上就要2016农历新年了,送点什么给大家呢?我觉得还是分享点技术吧.前不久用户在抱怨为什么登录Cognos Connection的密码不能让我们自己改?相信Cognos开发的很多人知道,Cognos ...
- VS2008+Windows DDK 7的环境配置(二)
在第一篇的基础上,进行如下的步骤,就可以编译出X64的驱动程序. (建议再另外建一个项目,这样避免混淆,因为x86和x64编译的有些编译选项是不同的.) 1. 安装VS2008 x64 build 组 ...
- Jade的奇怪解析问题。
如下的jade代码: span#span1 Span#span2 解析的时候span2总是变成span1的子元素.怎么解决? [解决方法] 用如下的代码就可以了. span#span1 | s ...
- elasticSearch nested exist与missing查询
elasticSearch nested查询,简单意义上,你可以理解为,它不会被索引,只是被暂时隐藏起来,而查询的时候,开关就是使用nested query/filter去查询 下面我有一个例子,是查 ...