Guest User

Untitled

a guest
Jul 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. #include<string.h>
  5.  
  6. int thuan_nghich(long n)
  7. {
  8. char s[100], t[100];
  9. ltoa(n, s, 10);
  10. strcpy(t, s);
  11. strrev(s);
  12. if(strcmp(s, t)==0) return(1);
  13. else return(0);
  14. }
  15.  
  16. void cs_ngto(long n)
  17. {
  18. char s[100];
  19. int k, i;
  20.  
  21. ltoa(n, s, 10);
  22. k=strlen(s);
  23. printf("\nCac chu so nguyen to: ");
  24. for(i=0; i<k; i++)
  25. if(s[i]=='2' || s[i]=='3' || s[i]=='5' ||s[i]=='7') printf(" %c", s[i]);
  26. }
  27.  
  28. void main()
  29. {
  30. long i;
  31.  
  32. for(i=1000000; i< 10000000; i++)
  33. if(thuan_nghich(i))
  34. {
  35. printf("\n%8ld", i);
  36. cs_ngto(i);
  37. }
  38. }
Add Comment
Please, Sign In to add comment