UVA 490 Java

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

留言

這個網誌中的熱門文章

C# 井字遊戲