1、个人认为题目点: a、有符号;b、考虑溢出问题;
public int Reverse(int x) { if (x.Equals(0)) { return x; } bool flag = false; if (x < 0) { x = 0 - x; flag = true; } char[] chr= x.ToString().Reverse().ToArray(); try { if (flag) { return 0 - Convert.ToInt32(new string(chr)); } else { return Convert.ToInt32(new string(chr)); } } catch { return 0; } }
转载于:https://www.cnblogs.com/chenking/p/10435573.html