andy6804tw
7/19/2016 - 4:16 PM

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=2554 這題就是讀入字串陣列然後從尾巴讀回頭

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=2554

這題就是讀入字串陣列然後從尾巴讀回頭

import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (scn.hasNext()) {
			String s[] = scn.nextLine().split(" ");
			for (int i = s.length - 1; i >= 0; i--) {
				if (i != s.length - 1)
					System.out.print(" ");
				System.out.print(s[i]);
			}
			System.out.println();
		}
	}
	
	/* 
    題目:[C_OT06-易] 英文句子字之倒轉
    作者:1010
    時間:西元 2016 年 7 月 */
}