翻转整型数(水题)

正题Reverse digits of an integer.Example1: x = 123, return 32Example2: x = -123, return -32思考改题为简单难度(水题),根据题意可以依次取到给定的整型数x的最高位到最低的数,然后依次将其乘10的x次幂后进行累加即可得到结果。这里,要知道32位的整型一共有九个0,故声明i=1000000000;代码[code lang="cpp"class Solution publicint reverse(int x) long int i = 1000000000, rev_i = 1, r = 0, start = 0;while (x != 0) int c = x / i;if (start == 0 && c != 0) start = 1;if (start == 0 && i /= 10;... Read More