标签:style blog http color os io 2014 art
解法:
1 class Solution { 2 public: 3 int reverse(int x) { 4 int signal = (x>0)? 1:-1; /* signal记录正负号 */ 5 x=abs(x); 6 int tmp = 0; 7 8 if(x == 0) 9 return x; 10 11 while(x) 12 { 13 tmp = tmp*10+x%10; 14 x = x/10; 15 } 16 17 tmp = tmp*signal; /* 乘上符号 */ 18 19 return tmp; 20 } 21 };
LeetCode : reverse integer,布布扣,bubuko.com
标签:style blog http color os io 2014 art
原文地址:http://www.cnblogs.com/crystal-miao/p/3874045.html