Problem : (1.2.1) Text Reverse
#include<iostream>
using namespace std;
void main()
{
char arr[1000];
int a,n;
int s,t;
cin>>a;
getchar();
for(int i=0;i<a;i++)
{
gets(arr);
n=strlen(arr);
s=0;
for(int j=0;j<=n;j++)
{
if(arr[j]==' '||arr[j]=='\0')
{
t=j;
for(int l=t-1;l>=s;l--)
{
cout<<arr[l];
}
s=t+1;
if(s!=n+1)
cout<<" ";
} }
cout<<endl;
}
}
|
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 |
|
Sample Output
hello world! |
Problem : (1.2.1) 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 ...
- (reverse) Text Reverse hdu1062
Text Reverse Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- 简单字符串处理 hdu1062 Text Reverse
虽然这个题目一遍AC,但是心里还是忍不住骂了句shit! 花了一个小时,这个题目已经水到一定程度了,但是我却在反转这个操作上含糊不清,并且还是在采用了辅助数组的情况下,关系的理顺都如此之难. 其实我是 ...
- 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 ...
- 杭电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开发艺术探索》读书笔记(十五)--Android性能优化
接上篇<android开发艺术探索>读书笔记(十四)--JNI和NDK编程 No1: 如果<include>制定了这个id属性,同时被包含的布局文件的根元素也制定了id属性,那 ...
- hihoCoder1319 岛屿周长 (bfs)
思路:从给定坐标开始bfs,将所有联通点标记,然后把每个联通点的四个方向都判断一下,如果这个方向相邻的是一个非联通点说明需要把这条边实在最外围,即周长的一部分. AC代码 #include <s ...
- POJ - 2253 Frogger 单源最短路
题意:给定n个点的坐标,问从第一个点到第二个点的最小跳跃范围.d(i)表示从第一个点到达第i个点的最小跳跃范围. AC代码 #include <cstdio> #include <c ...
- Java中的return关键字
Java常见面试题之一: try {}里有一个return语句,那么紧跟在这个try后的finally {}里的code会不会被执行,什么时候被执行,在return前还是后? 请看下面程序就可以解释 ...
- Web开发框架推导
本文欲回答这样一个问题:在 「特定环境 」下,如何规划Web开发框架,使其能满足 「期望 」? 假设我们的「特定环境 」如下: 技术层面 使用Java语言进行开发 通过Maven构建 基于Spring ...
- mysql一些使用技巧
1.查看系统帮助文档:HELP contents; 2.查看所有支持的数据类型:HELP Data Types; 3.查看对应的数据类型的详细信息:HELP 类型:如HELP INT; 4.查看存储引 ...
- 求sum=1+111+1111+........+1....111 .
1,思路 大数相加,若直接使用int,或者long都会超出长度,因此考虑使用String存储. 2,代码 public class LargeNumAdd { public static void m ...
- 【mongodb系统学习之九】mongodb保存数据
九.mongodb保存数据: 1).插入.保存数据:insert:语法db.collectionName.insert({"key":value}),key是字段名,必须是字符串( ...
- e.preventDefault()和e.stopPropagation()以及return false的作用和区别
前段时间开发中,遇到一个父元素和子元素都有事件时,发现会出现事件冒泡现象,虽然知道ev.stopPropagation()和ev.preventDefault()其中一个是阻止事件冒泡和阻止默认行为, ...
- iOS - GATT Profile 简介
1.引言 现在低功耗蓝牙(BLE)连接都是建立在 GATT (Generic Attribute Profile) 协议之上.GATT 是一个在蓝牙连接之上的发送和接收很短的数据段的通用规范,这些很短 ...