(reverse) Text Reverse hdu1062
Text Reverse
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 35208 Accepted Submission(s): 13824
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>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int n;
char a[];
cin>>n;
getchar(); //别忘了要输入。
while(n--)
{
gets(a);
int len = strlen(a);
int s=,e=;
for(int i=;i<len;i++)
{
if(a[i]==' ')
{
e = i;
reverse(a+s,a+e); //对于C语言的字符串表示方式使用,但是对于string并不适用。
s=e+;
}
}
if(a[len-]!=' ') //要考虑每行的字符串的最后一个字符是否为空格。
{
e = len;
reverse(a+s,a+e);
}
printf("%s\n",a);
}
return ;
}
(reverse) Text Reverse hdu1062的更多相关文章
- HD-ACM算法专攻系列(7)——Text Reverse
问题描述: 源码: /**/ #include"iostream" #include"string" using namespace std; void Pri ...
- LeetCode(68) Text Justification
题目 Given an array of words and a length L, format the text such that each line has exactly L charact ...
- Javascript高级编程学习笔记(38)—— DOM(4)Text
Text类型 html页面中的纯文本内容就属于Text类型 纯文本内容可以包含转义后的html字符,但不能包括 html 代码 text类型具有以下属性.方法 nodeType:3 nodeName: ...
- React Native组件(三)Text组件解析
相关文章 React Native探索系列 React Native组件系列 前言 此前介绍了最基本的View组件,接下来就是最常用的Text组件,对于Text组件的一些常用属性,这篇文章会给出简单的 ...
- SHELL/VIM删除重复行(去重)text handle
vim 删除重复行 - 国内版 Binghttps://cn.bing.com/search?FORM=U227DF&PC=U227&q=vim+%E5%88%A0%E9%99%A4% ...
- 文件名后面加(1).text
; //在重复名称后加(序号) while (File.Exists(path)) { if (path.Contains(").")) { int start = path.La ...
- (转)EntityFrameword “Reverse Engineer Code First” 连接 MySql
转自:http://stackoverflow.com/questions/19676624/error-trying-to-reverse-engineer-code-first-mysql-dat ...
- LeetCode(150) Evaluate Reverse Polish Notation
题目 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, ...
- leetcode解题报告(27):Reverse Linked List
描述 Reverse a singly linked list. 分析 一开始写的时候总感觉没抓到要点,然后想起上数据结构课的教材上有这道题,翻开书一看完就回忆起来了,感觉解法挺巧妙的,不比讨论区的答 ...
随机推荐
- c++ 中关于一些变量不能声明的问题
j0,j1,jn,y0,y1,yn被c++中某些函数占用了,所以是不能被声明的,今天就遇到了这个问题,结果我在自己写的程序中找了半天都没找到重复申明的y1
- Visual Studio的安装与单元测试
一.Visual Studio的安装 由于上学期重装了win10系统,以前使用的vc++6.0不能够正常使用,所以直接就安装了Visual Studio 2015,安装的时候就直接按照提示的步骤进行安 ...
- SE Class's Individual Project--12061161 赵梓皓
1. 项目预计的用时 其实刚开始以为这个项目不难写,因为上学期oo课程上用java写过类似的程序(貌似还比这个复杂).觉得主要的难点在于学习c++语言. 总的项目被分为大概3个部分. 其一,文件遍历. ...
- 【个人博客作业Week7】软件工程团队项目一轮迭代感想与反思
(发布晚原因:发到团队博客了 一.关于银弹 在佛瑞德·布鲁克斯于1986年发布的<没有银弹:软件工程的本质性与附属性工作>这篇软件工程的经典论文中,作者向我们讲述了软件工程没有银弹这样的理 ...
- android开发之Tabhost刷新
在android中,使用tabHost的时候,如果tab被点击,该tab所对应的activity被加载了,从别的tab切换回来的时候,activity不会再次被创建了(onCreate),所以要想每次 ...
- 软件工程(五)UML
UML 统一建模语言,又称标准建模语言.是用来对软件密集系统进行可视化建模的一种语言.包括UML语义和UML表示法两个元素. UMl图由事物和关系组成,事物:UML模型中最基本的构成元素,是具有代表性 ...
- Rabbitmq vs. kafka
https://mp.weixin.qq.com/s/2i_9TWoF3TsJvG6Dj_75vw http://www.cnblogs.com/valor-xh/p/6348009.html htt ...
- 使用kindeditor来替换ecshop的fckeditor编辑器,让ecshop可以批量上传图片
老杨原创 kindeditor此编辑器可以让ecshop批量上传图片,可以插入代码,可以全屏编辑,可以插入地图.视频,进行更多word操作,设置字体. 步骤一:进入kindeditor的官网,http ...
- [转帖]一文看懂web服务器、应用服务器、web容器、反向代理服务器区别与联系
一文看懂web服务器.应用服务器.web容器.反向代理服务器区别与联系 https://www.cnblogs.com/vipyoumay/p/7455431.html 我们知道,不同肤色的人外貌差别 ...
- SourceTree 如何下载git 管理的代码-如何创建分支,删除分支,提交代码,回退代码
把用户给的链接拿过来,然后输入浏览器,然后在左侧会有Actions 中有个Clone;点击Clone之后,有个 Clone in Source Tree 点击,打开你的本地Source Tree,然后 ...