您的位置:首页 > 其它

输入一个数,将顺序逆转,例如输入123,输出321

2018-01-19 09:30 806 查看
实现代码如下:
package test;

public class Test5 {
public static int reverse(int x) {
long result = 0;
while(x!=0){
int n = x%10;
result = result*10+n;
x=x/10;
}
if( result > Integer.MAX_VALUE || result < Integer.MIN_VALUE)
return 0;
return (int)result;
}
public static void main(String[] args) {
int x=153423646;
int y = Test5.reverse(x);
System.out.println(y);
}

}
如果你有更好的方法,请加QQ群691761026一起交流
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐