作者:青岛大学MBA校友件_176 | 来源:互联网 | 2023-09-07 11:39
题目:
Reverse a 3-digit integer.
Example
Reverse 123
you will get 321
.
Reverse 900
you will get 9
.
Code:
class Solution {
public:
/**
* @param number: A 3-digit number.
* @return: Reversed number.
*/
int reverseInteger(int number) {
int size = 0;
int count_number = number;
while (count_number / 10 != 0) {
count_number = count_number / 10;
size++;
}
size++;
int res = 0;
int temp = 0;
int count_size = size-1;
int dig = 1;
int temp_number = number;
for (int i = 0;i