• 进制回文数


     1 #include <stdio.h>
     2 bool huiwen(char a[], int n){
     3 
     4     int i, j;
     5     i = 0; j = n - 1;
     6 
     7     while (i < j){
     8         if (a[i] != a[j])
     9             return false;
    10         i++;
    11         j--;
    12     }
    13 
    14     return true;
    15 }
    16 
    17 int main(){
    18     char buffer[1001];
    19     int a;
    20     int temp;
    21     int counter = 0;
    22     int i;
    23     while (scanf("%d", &a) != EOF){
    24         int b = a;
    25         for ( i = 2; i <= 16; i++){
    26             b = a;
    27             counter = 0;
    28             while (b){
    29                 temp = b % i;
    30                 b /= i;
    31                 if (temp >= 10){
    32                     buffer[counter] = temp - 10 + 'A';
    33                 }
    34                 else{
    35                     buffer[counter] = temp + '0';
    36                 }
    37                 counter++;
    38             }
    39 
    40             //printf("i = %d, counter = %d
    ", i, counter);
    41             if (huiwen(buffer, counter)){
    42                 break;
    43             }
    44 
    45         }//end for
    46 
    47         if (i >= 17){
    48             printf("No
    ");
    49         }
    50         else{
    51             printf("Yes
    ");
    52         }
    53     }
    54 
    55 }
  • 相关阅读:
    莫队总结
    三、模型层(二)
    二、模型层(一)
    五、web杂项
    一. Django入门
    二、js
    一、html和css
    二十一、正则表达式
    END:小练习、涨知识
    二十、协程
  • 原文地址:https://www.cnblogs.com/ouyang_wsgwz/p/8511219.html
Copyright © 2020-2023  润新知