AOJ 0006 Reverse Sequence
方針
StringBuilderクラスのreverseメソッドを使いました。これで一発です。
例:
String example = new StringBuilder("Akensho").reverse().toString(); System.out.println(example);
出力結果はohsnekAです。
ソース
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static String input; public static void main(String[] args) { while(read()){ slove(); } } static boolean read(){ if(!sc.hasNext())return false; input = sc.nextLine(); return true; } static void slove(){ String res = new StringBuilder(input).reverse().toString(); System.out.println(res); } }