题解 | #数字颠倒#
数字颠倒
http://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
package HJ;
import java.util.Scanner;
public class HJ11 {
public static void main(String[] args) {
//以下两个写法原理一样,只是写法不同。
// ** 写法一:**
// Scanner sc = new Scanner(System.in);
// int in = sc.nextInt();
// String sin = String.valueOf(in);
// StringBuilder sb = new StringBuilder();
// for(int i=sin.length()-1; i>=0; i--){
// sb.append(sin.charAt(i));
// }
// System.out.println(sb.toString());
// ** 写法二:**
Scanner sc = new Scanner(System.in);
int in = sc.nextInt();
String sin = String.valueOf(in);
StringBuilder sb = new StringBuilder(sin);
sb.reverse();
System.out.println(sb);
}
}