Problem Link: UVA10018 Reverse and Add. Basic Training questions, written in C language program.
Test instructions: Enter the number of test cases N, and then enter n positive integers, plus the integer in reverse order, if and not palindrome number , and the inverse of the integer and sum, until it becomes a palindrome integer, at least one addition, the last output addition number and palindrome number.
In the program, the function of calculating the inverse integer is encapsulated into the function reverse () and the main program logic becomes simple.
Use function encapsulation function, make the program function logical localization, the program is more concise and understandable.
The C language Program of AC is as follows:
/* UVA10018 Reverse and ADD */#include <stdio.h>unsigned int Reverse (unsigned int n) { int rev = 0; while (n) { Rev = rev * + N; n/=; } return rev;} int main (void) { int n, count; unsigned p, rev; scanf ("%d", &n); while (n--) { scanf ("%d", &p); Rev = reverse (p); p + = rev; Count = 1; Rev = reverse (p); while (P! = rev) { p + = rev; count++; Rev = reverse (P); } printf ("%d%u\n", count, p); } return 0;}
UVA10018 Reverse and Add