[C] C语言 回文数 →→→→→进入此内容的聊天室

来自 Obese Macaque, 2024-03-26, 写在 C, 查看 17 次.
URL http://www.code666.cn/view/ddabbac6
  1. 题目:一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。
  2.  
  3.  
  4. #include <stdio.h>
  5.  
  6. int main( )
  7. {
  8.     long ge,shi,qian,wan,x;
  9.     printf("请输入 5 位数字:");
  10.     scanf("%ld",&x);
  11.     wan=x/10000;        /*分解出万位*/
  12.     qian=x%10000/1000;  /*分解出千位*/
  13.     shi=x%100/10;       /*分解出十位*/
  14.     ge=x%10;            /*分解出个位*/
  15.     if (ge==wan&&shi==qian) { /*个位等于万位并且十位等于千位*/
  16.         printf("这是回文数\n");
  17.     } else {
  18.         printf("这不是回文数\n");
  19.     }
  20. }

回复 "C语言 回文数"

这儿你可以回复上面这条便签

captcha