> 其他 >
一个5位数,判断它是不是回文数.即12321是回文数,个位与万位相同,十位与千位相同.C语言编程
人气:353 ℃ 时间:2020-01-31 00:59:41
解答
分解出个位,十位,千位和万位的数字.
#include <stdio.h>
void main()
{
    long ge, shi, qian, wan, x;
    printf("Please enter a five-digit number: ");
    scanf("%ld",&x);
    wan=x/10000;
    qian=x%10000/1000;
    shi=x%100/10;
    ge=x%10;
    if(ge == wan && shi == qian)  /*个位等于万位并且十位等于千位*/
        printf("This number is a HuiWen.\n");
    else
        printf("This number is not a HuiWen.\n");
}
请放心使用,有问题的话请追问
采纳后你将获得5财富值.
你的采纳将是我继续努力帮助他人的最强动力!
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版