oj赛氪算法练习

单词翻转

oj赛氪算法练习_第1张图片



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);
        }
    }
}

你可能感兴趣的:(算法练习,算法,c#,开发语言)