using System;
using System.Collections.Generic;
class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param x int整型
* @return int整型
*/
public int reverse (int x) {
// write code here
int flag=1;
if(x<0)
{
x=-x;
flag=-1;
}
var n=0;
while(x>0)
{
if(n>(int.MaxValue-x%10)/10)
return 0;
n=n*10+x%10;
x=x/10;
}
return flag*n;
}
}



京公网安备 11010502036488号