您的位置:首页 > 其它

leetCode题解

2016-03-10 20:48 274 查看
leetcode题解

(1)题目:

Given an input string, reverse the string word by word.

For example,

Given s = “the sky is blue”,

return “blue is sky the”.

使用java实现代码:

package leetcode;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class onecode {

public static void main(String[] args) throws IOException

{

BufferedReader strin=new BufferedReader(new InputStreamReader(System.in));

System.out.print(“请输入一个字符串:”);

String str = strin.readLine();

String array[]=str.split(” “);

String printout=”“;

for(String item:array)

{

printout=item+” “+printout;

}

System.out.println(printout);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: