黑马程序员技术交流社区

标题: 给大家出道题吧。去年的考研题 [打印本页]

作者: 尘封印际    时间: 2015-7-6 21:18
标题: 给大家出道题吧。去年的考研题
hello world welcome to java
每个单词倒叙输出。
输出结果是: olleh dlrow emoclew ot avaj
作者: 尘封印际    时间: 2015-7-6 21:19
public class Print {
public static void main(String[] args) {
        String word = "hello world welcome to java";
        String [] s=word.split(" ");
       
        for (int i = 0; i < s.length; i++) {
                for (int j = s[i].length()-1; j >=0 ; j--) {
                        System.out.print(s[i].charAt(j));
                }
                System.out.print(" ");
        }
}
}





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2