回文数

#include <stdlib.h>
#include <math.h>
#include <iostream>
using namespace std;

bool hui_number(int n){
    int t=n;
    int k=0;
    int a[10];
    while(t>0){               //提前数的每一位保存到数组 
        a[k]=t%10;
        t=t/10;
        k++;
    }
    for(int i=0;i<k/2;i++){
        if(a[i]!=a[k-i-1]) return false;
    }
    return true;
}

int main(){
    int m;
    cin>>m;
    cout<<hui_number(m);
    return 0;
} 

 

posted @ 2021-01-10 22:23  Maxwell·  阅读(54)  评论(0编辑  收藏  举报