单词翻转



import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String sentence = scanner.nextLine();

        String[] words = sentence.split(" ");

        for (String word : words) {
            StringBuilder reversedWord = new StringBuilder(word).reverse();
            System.out.println(reversedWord);
        }
    }
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注