1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * UVA490 */ public class UVA490 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); List<String> input = new ArrayList<String>(); int max = 0; int maxLine = 0; while (sc.hasNextLine()) { String temp = sc.nextLine(); input.add(temp); if (max <= temp.length()) { max = temp.length(); maxLine = input.size() - 1; } } for (int i = 0; i < max; i++) { for (int j = input.size() - 1; j >= 0; j--) { String temp = input.get(j); if (temp.length() > i) System.out.print(temp.charAt(i)); else if (j > maxLine) System.out.print(" "); } System.out.println(); } sc.close(); } } |