求回文数

  int reser (int x) //把x倒过来
  {
      int _x = 0;
      while (x != 0)
      {
          _x = _x * 10 + x % 10;
          x /= 10;
      } 
      return _x;
 }
 
 bool isHW (int num) //判断是否回文
 {
     if (num == reser(num))
         return true;
     else
         return false;
 }

 

posted @ 2021-07-31 09:40  白藏i  阅读(54)  评论(0)    收藏  举报