Advertisement
Guest User

Một số được coi là số đẹp nếu nó là số thuận nghịch, có chứa

a guest
Jun 13th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1.  
  2. int STN(int n)
  3. {
  4.     int m = n;
  5.     int tg = 0;
  6.     while(m)
  7.     {
  8.         tg=tg*10 + m%10;
  9.         m/=10;
  10.     }
  11.    
  12.     if(tg==n) return 1;
  13.     return 0;
  14. }
  15.  
  16. int So(int n)
  17. {
  18.     int no = 0;
  19.     while(n)
  20.     {
  21.         no=n%10;
  22.         if((STN(no))!=6) return 0;
  23.         n/=10;
  24.     }
  25.    
  26.     return 1;
  27. }
  28.  
  29. int Tong(int n)
  30. {
  31.     int tn = 0;
  32.     while(n)
  33.     {
  34.         tn+=n%10;
  35.         n/=10;
  36.        
  37.     }
  38.    
  39.     if((STN(tn%10))==8) return 1;
  40.     return 0;
  41. }
  42.  
  43. main()
  44. {
  45.     int i,a,b;
  46.     scanf("%d", &a);
  47.     scanf("%d", &b);
  48.     for(i=a; i<=b; i++)
  49.     if(STN(i)&&So(i)&&Tong(i))
  50.     printf("\n%d", i);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement