HDOJ/HDU 1062 Text Reverse(字符串翻转~)
发布日期:2021-06-29 13:35:53
浏览次数:2
分类:技术文章
本文共 1518 字,大约阅读时间需要 5 分钟。
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 .mcaSample 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.题意:
输入一行字符串,将每一个单词(只有空格隔开)倒序输出!注意:
开始和结尾可能有多个空格,单词之间可能有多个空格!PE的请注意:空格必须照原样输出!有几个输出几个,不能多输出也不能少输出!
import java.util.Scanner;/** * @author 陈浩翔 * 2016-5-25 */public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t =sc.nextInt(); sc.nextLine();//读取输入t之后的回车 while(t-->0){ String str=sc.nextLine(); String s[] = str.split(" "); String str2=""; for(int i=0;i=0;k--){ System.out.print(s[i].charAt(k)); str2+=s[i].charAt(k); } if(i!=s.length-1){ System.out.print(" "); str2+=" "; } } for(int i=str2.length();i
转载地址:https://chenhx.blog.csdn.net/article/details/51499790 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
感谢大佬
[***.8.128.20]2024年04月21日 03时07分25秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
自我学习37:请描述一下网页从开始请求到最后展示的完整过程
2019-04-29
自我学习38:如何区分前后端BUG
2019-04-29
自我学习39:接口自动化测试用例&功能测试用例区别
2019-04-29
mirror去兔子补丁下载 附安装教程
2019-04-29
mirror去兔子补丁 v3.0附安装教程
2019-04-29
mirror去兔子补丁为什么还有兔子_mirror去兔子补丁使用教程
2019-04-29
3dmax2012安装教程
2019-04-29
OC渲染器(Octane Render)整合版安装包 附安装教程
2019-04-29
操作系统期末大题复习
2019-04-29
hive:分区表,hbase外表
2019-04-29
想要成为运维,想要成为后期的架构师?这些知识是必备的!
2019-04-29
linux 是如何 快速一键安装禅道的呐?
2019-04-29
运维面试基础试题(四)
2019-04-29
一键安装Openstack单节点 必能成功
2019-04-29
面试紧张怎么办
2019-04-29
关系型数据库 ,nosql数据库简介
2019-04-29
Centos 7搭建NTP时间同步服务器
2019-04-29
centos7 基于rsync+inotify 实现定时备份
2019-04-29
指定IP进行 文件的分发
2019-04-29
基于http搭建本地yum仓库
2019-04-29