public class TEST {
public long reverse(long num){
String strnum = String.valueOf(num);
StringBuffer buffer = new StringBuffer();
for(int i=0;i<strnum.length();i++){
buffer.append(strnum.charAt(strnum.length()-i-1));
}
long target = Integer.parseInt(buffer.toString());
return target;
}
public static void main(String[] args) {
long num = 248765432;
TEST test = new TEST();
System.out.println(test.reverse(num));
}
}
java:输入一个数,反转后输出
最新推荐文章于 2024-09-03 00:10:53 发布