All of the definitions of palindrome numbers and how to determine whether a D-number is a palindrome is in my code comments, directly on the code:
#include <stdio.h>intCircleintNintD);/** * @brief Main to determine whether the D-Binary of positive integer n is a palindrome number * @return * /intMainvoid){/** * palindrome number, is to look down and backward to see the same book, such as n=232, the decimal book is expressed as 232, * along the look and look upside down is 232, it means that n is a palindrome number * to determine whether the D-ary is a palindrome there are two ways * 1: First convert N to D The binary representation, then the two pointers are in front and back and forward * simultaneously, compare whether two char is equal * * 2: First order the D binary number of N, and then convert the numbers from low to high to a * integer to see if n is equal * * Here we use the second way * * intN//positive integer to be judged //Save in binary number intDs[] = {2,Ten, -}; printf"Please enter the integer n:\n"); scanf"%d", &n);inti =0; for(i =0; i < sizeof (DS)/sizeof (ds[0]); i++) {intIscircle = 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 a positive integer n's * d is a palindrome number * @param n is the positive integer that is judged n * @param /c4> d number * @return 1-is a palindrome number, 0-not a palindrome number */intCircleintNintD) {ints =0;intm = n; while(m) {s = s * d + m% d; M/= D; }returns = = n;}
Here are the results of my program's operation:
c Determines whether the D-number of a positive integer n is a palindrome