https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=6&problem=424&mosmsg=Submission+received+with+ID+17582033 困難度 ★★ *這題要注意字串最尾巴不能也有空白必須用判斷式否則會Presentation error
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn=new Scanner (System.in);
while(scn.hasNext()){
String str=scn.nextLine();
String arr[]=str.split(" ");
for(int i=0;i<arr.length;i++){
StringBuffer sb = new StringBuffer();
sb.append(arr[i]);
sb.reverse();
System.out.print(sb);
if(i!=arr.length-1)System.out.print(" ");
}
System.out.println("");
}
}
/*
題目:Q483: Word Scramble
作者:1010
時間:西元 2016 年 6 月 */
}