(String)将一个String里面的单词反转
e.g. i love java return java love i
public static String reverseStr(String str) {
String[] strs=str.split(" ");
StringBuilder sb=new StringBuilder();
for(int i=strs.length-1;i>=0;i--) {
sb.append(strs[i]+" ");
}
return sb.toString();
}
(String)将一个String里面的单词反转的更多相关文章
- [LeetCode] Reverse Words in a String 翻转字符串中的单词
Given an input string, reverse the string word by word. For example, Given s = "the sky is blue ...
- 151 Reverse Words in a String 翻转字符串里的单词
给定一个字符串,翻转字符串中的每个单词.例如,给定 s = "the sky is blue",返回 "blue is sky the".对于C程序员:请尝试用 ...
- 151. Reverse Words in a String翻转一句话中的单词
[抄题]: Given an input string, reverse the string word by word. Example: Input: "the sky is blue& ...
- [LeetCode] 151. Reverse Words in a String 翻转字符串中的单词
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue& ...
- [LintCode] Reverse Words in a String 翻转字符串中的单词
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue& ...
- 345. Reverse Vowels of a String【Easy】【双指针-反转字符串中的元音字符】
Write a function that takes a string as input and reverse only the vowels of a string. Example 1: In ...
- Lua的string和string库总结
Lua有7种数据类型,分别是nil.boolean.number.string.table.function.userdata.这里我总结一下Lua的string类型和string库,复习一下,以便加 ...
- c# 各种排序算法+找第二大的数+句子单词反转
冒泡排序 // 冒泡排序 bubble sort public static int[] BubbleSort(int []array) { bool isContinue = true; ; i & ...
- Java提高篇——理解String 及 String.intern() 在实际中的应用
1. 首先String不属于8种基本数据类型,String是一个对象. 因为对象的默认值是null,所以String的默认值也是null:但它又是一种特殊的对象,有其它对象没有的一些特性. 2. ...
随机推荐
- 总结七条助你成为Linux高手的超棒忠告
起初Linux对于我来说其实是很纠结的,因为很早以前就听说过.也曾见各种技术大牛使用过,但是一直觉得非常高深而没有去正式接触.两年前随着自己工作愈发的乏味,又看到了一篇叫做"虽然我是医生,但 ...
- [ie兼容]ie7浮动左在前,浮动右在后导致右边浮动的元素掉下来
解决办法:左浮动和右浮动元素在结构上互换位置 http://blog.sina.com.cn/s/blog_818a1e5b0100wp5b.html
- Five More Hacker Tools Every CISO Should Understand
As we mentioned in the first article, Top Five Hacker Tools Every CISO Should Understand, the role o ...
- C++ / CLI 调用 C++ /Native 随记
C# 封装 原生C++ 方法:1.C++ CLR(托管) 调用 C++(原生)2.C#调用C++ CLR , 注意各个平台编译版本需一致.3.C# 默认编绎生成版本是 any cpu , 需修改成 ...
- hdu 1036 (I/O routines, fgets, sscanf, %02d, rounding, atoi, strtol) 分类: hdoj 2015-06-16 19:37 32人阅读 评论(0) 收藏
thanks to http://stackoverflow.com/questions/2144459/using-scanf-to-accept-user-input and http://sta ...
- enmo_day_09
1. 数据库 select name from v$database; : 数据库名称 select db_unique_name from v$database; : 数据库唯一名称 select ...
- DDOS的攻击原理和防护指南(转)
DDOS的攻击原理和防护指南 作者:冰盾防火墙 网站:www.bingdun.com 日期:2008-01-07 我们现在来分析DDOS的攻击原理. 首先,DDOS是英文Distribut ...
- 1、c#对XML文件的解析
1.XML文件 <?xml version="1.0" encoding="utf-8"?> <PersonF xmlns="&qu ...
- Gym 100818G (模拟退火)
题目大意 给一张n个点的无向图,要求给每个点染色0或1,使得每个点的相邻相同颜色点的数量小于等于其度数的一半. 解题分析 没想到什么好的算法,就随机乱搞了. 若某个状态时,一个点的度数为cnt,相邻相 ...
- select、poll、poll的比较(转)
原文地址:http://www.cnblogs.com/xuxm2007/archive/2011/08/15/2139809.html select.poll.epoll的比较 linux提供了se ...