UVA490




Sample Input


Rene Decartes once said,
"I think, therefore I am."

Sample Output


"R
Ie
 n
te
h 
iD
ne
kc
,a
 r
tt
he
es
r
eo
fn
oc
re
e
 s
Ia
 i
ad
m,
.
"
解法: 儲存每串句子 依次往下輸出每個句子的一個字元 (注意空格)
import java.util.*;

public class UVA490 {

 public static void main(String[] args) {

  ArrayList<String> AS = new ArrayList<String>();

  Scanner sc = new Scanner(System.in);

  int maxLen = 0;

  while (sc.hasNext()) {

   // for(int i =0;i<3;i++){

   AS.add(sc.nextLine());

   if (maxLen < AS.get(AS.size() - 1).length()) {

    maxLen = AS.get(AS.size() - 1).length();
   }

  }

  for (int j = 0; j < maxLen; ++j) {

   for (int i = AS.size() - 1; i >= 0; --i) {

    if (j < AS.get(i).length())
     System.out.print(AS.get(i).charAt(j));

    else
     System.out.print(" ");
   }

  }

  sc.close();
 }

}