直接反向打印就可以
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
while (sc.hasNextLine()) {
String str = sc.nextLine();
int length = str.length();
for (int i = length -1; i >=0; i--) {
System.out.print(str.charAt(i));
}
}
}
}