解答一:
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
String str=sc.next();
char[] charArray=str.toCharArray();
for(int i=charArray.length-1;i>=0;i--){
System.out.print(charArray[i]);
}
}
}
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
String str=sc.next();
char[] charArray=str.toCharArray();
for(int i=charArray.length-1;i>=0;i--){
System.out.print(charArray[i]);
}
}
}
解答二:
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
StringBuilder sb=new StringBuilder(str);
System.out.print(sb.reverse());
}
}
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
StringBuilder sb=new StringBuilder(str);
System.out.print(sb.reverse());
}
}