Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<stdlib.h>
- #include<string.h>
- int thuan_nghich(long n)
- {
- char s[100], t[100];
- ltoa(n, s, 10);
- strcpy(t, s);
- strrev(s);
- if(strcmp(s, t)==0) return(1);
- else return(0);
- }
- void cs_ngto(long n)
- {
- char s[100];
- int k, i;
- ltoa(n, s, 10);
- k=strlen(s);
- printf("\nCac chu so nguyen to: ");
- for(i=0; i<k; i++)
- if(s[i]=='2' || s[i]=='3' || s[i]=='5' ||s[i]=='7') printf(" %c", s[i]);
- }
- void main()
- {
- long i;
- for(i=1000000; i< 10000000; i++)
- if(thuan_nghich(i))
- {
- printf("\n%8ld", i);
- cs_ngto(i);
- }
- }
Add Comment
Please, Sign In to add comment