public class text2 {
public static void main(String[] argv){
//String s="123";
int i=123;
aa(i);
}
public static void aa(int s){
}
}
写一个int型的逆排序。例如:123,输出是:321.请问高手怎么写?
public static void main(String[] argv){
//String s="123";
int i=123;
aa(i);
}
public static void aa(int s){
}
}
写一个int型的逆排序。例如:123,输出是:321.请问高手怎么写?
Integer.parseInt(new StringBuffer(new Integer(12345).toString()).reverse().toString())
System.out.println(new StringBuffer().append(i).reverse());
int[] nums = { -123456, 0, 123456 };
for (int n : nums) {
System.out.println(reverse(n));
}
} private static int reverse(int num) {
int k = 0;
for (int i = num; i != 0; i /= 10) {
k = k * 10 + (i % 10);
}
return k;
}
}
String str = "123";
System.out.println(new StringBuffer(str).reverse());