🌕🌑🌑🌑🌑

# 題目連結

  • 題目連結
  • Online Judge
  • uDebug

# 題目說明

Time limit: 3.000 seconds

# 題目

In “Rotating Sentences,” you are asked to rotate a series of input sentences 90 degrees clockwise. So instead of displaying the input sentences from left to right and top to bottom, your program will display them from top to bottom and right to left.

# Input

As input to your program, you will be given a maximum of 100 sentences, each not exceeding 100 characters long. Legal characters include: newline, space, any punctuation characters, digits, and lower case or upper case English letters. (NOTE: Tabs are not legal characters.)

# Output

The output of the program should have the last sentence printed out vertically in the leftmost column; the first sentence of the input would subsequently end up at the rightmost column.

# 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,
.
"

# 解題技巧

# Solution

Main.java
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> list = new ArrayList<>();
        int max = 0;
        while(sc.hasNextLine()){
            String input = sc.nextLine();
            list.add(input);
            max = Math.max(max, input.length());
        }
        for(int i = 0; i < max; i++){
            for(int j = list.size() - 1; j >= 0; j--){
                String temp = list.get(j);
                if(temp.length() > i){
                    System.out.print(temp.charAt(i));
                }else{
                    System.out.print(" ");
                }
            }
            System.out.println("");
        }
        sc.close();
    }
}
單字

** **
!! !!

片語 & 搭配詞

!! !!