Guest User

Untitled

a guest
Sep 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <limits.h>
  4.  
  5. char allow[5][2] = { {'0','0'}, {'1','1'}, {'6','9'}, {'8','8'}, {'9','6'} } ;
  6.  
  7. int pass( char *str ) {
  8.   int len = strlen(str);
  9.  
  10.   int s, e, j ;
  11.   for ( s = 0 , e = len-1 ; s<=e ; s++, e-- ) {
  12.     for ( j = 0 ; j < 5 ; j++ ) {
  13.       if ( str[s] == allow[j][0] && str[e] == allow[j][1] )
  14.         break;
  15.     }
  16.     if ( ! ( j < 5 ) ) return 0 ;
  17.   }
  18.   return 1 ;
  19. }
  20.  
  21. int main() {
  22.   char str[100] ;
  23.  
  24.   for ( int i = 0 ; i <=  INT_MAX ; i++ ) {
  25.     sprintf(str,"%d", i ) ;
  26.     if ( pass(str) )
  27.       printf("%d\n",i) ;
  28.   }
  29.  
  30.  
  31.   return 0 ;
  32. }
Add Comment
Please, Sign In to add comment