这段小程序可以求出一定范围内的回文数,即形如:787,1111,1221的这类数字

  1. #include <stdio.h> 
  2.  #define M 1000 
  3.    
  4.  int main(int argc,char *argv[]) 
  5.  { 
  6.      long a,b,c; 
  7.      for(a=10;a<=M;a++) 
  8.      { 
  9.          b=0; 
  10.          c=a; 
  11.          while(c!=0) 
  12.          { 
  13.              b=b*10+c%10; 
  14.              c/=10; 
  15.          } 
  16.          if(b==a) 
  17.          { 
  18.              printf("%d",a); 
  19.          } 
  20.      } 
  21.      return 0; 
  22.  }