Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Help write a C++ program, use recursive function to inverse integer, and write a main function to judge whether it is a return number. Example 1232 1 is the return number, but 123 is not.
Help write a C++ program, use recursive function to inverse integer, and write a main function to judge whether it is a return number. Example 1232 1 is the return number, but 123 is not.
# include & ltiostream & gt

Use namespace std

Long Reverse (Long Number) {

If (number/10 == 0)

Quantity returned;

Otherwise {

long temp = number,sum = number% 10。

while(temp/ 10! = 0){

sum * = 10;

temp/= 10;

}

Returns the sum+inverse (number/10);

}

}

int main(){

long num = 12332 1;

cout & lt& ltnum & lt& ltendl

Cout & lt& lt "After the reverse!" & lt& ltendl

Cout & lt& lt reverse (number)<& ltendl

if(num == reverse(num))

Cout & lt& lt "palindrome number!" & lt& ltendl

Else cout & lt& lt "is not palindrome!" & lt& ltendl

System ("suspended");

Returns 0;

}

Judging the recursive version of C++ by palindrome, it was debugged in VS2008.