C. Determine whether the number of hexadecimal Integers of a positive integer n is a return number.
All the methods for defining the number of input files and how to determine whether a n d-base number is a number of input files are included in my code comments, and the code is directly:
# Include <stdio. h> int circle (int n, int d);/*** @ brief main judge whether the number of return texts is in the d hexadecimal notation of positive integer n * @ return */int main (void) {/*** refers to the number of replies, that is, reading the same book as reading it backwards. For example, n = 232 indicates that the decimal book is 232. * reading and reading are both 232, it indicates n is the number of input files * There are two ways to judge whether n is in the d-base representation of n * 1: Convert n to the d-base representation first, then, the two pointers are computed simultaneously from the front to the back and from the back * To compare whether the two char values are equal. ** 2: first, the number of d-hexadecimal numbers of n is obtained, then convert the numbers from low to high to an integer to see if they are equal to n ** here we use the second method */int n; // positive integer to be judged // Save the hexadecimal number int ds [] = {2, 10, 16}; printf ("Please enter the integer N: \ n "); scanf (" % d ", & n); int I = 0; for (I = 0; I <sizeof (ds) /sizeof (ds [0]); I ++) {int isCircle = circle (n, ds [I]); if (isCircle = 0) {printf ("% d => <% d>: is not circle! \ N ", n, ds [I]);} else {printf (" % d => <% d>: is circle! \ N ", n, ds [I]) ;}} return 0 ;} /*** @ brief circle this function is used to determine whether the X-d hexadecimal number of a positive integer n is a return x @ param n the positive integer n * @ param d hexadecimal number *@ return 1-the number of replies, 0-not the number of input records */int circle (int n, int d) {int s = 0; int m = n; while (m) {s = s * d + m % d; m/= d;} return s = n ;}
The following is the running result of my program: