判斷整數是否是迴文

#include <stdio.h>
void main(){
    int num,tmp,x=0;
    //x是一點點被倒過來的數,用來和原數比較
    scanf("%d",&num);
    tmp = num;
    while(tmp > 0){
        x = x*10 + tmp%10;
        tmp = tmp/10;
    }
    if(x == num){
        printf("y");
    }
    else
        printf("n");
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章