Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // tinh tong cac chu so nguyen to
- // Khai bao cac ham thu vien neu co
- #include<stdio.h>
- #include<conio.h>
- int NT(int x)
- {
- int dem=0;
- for(int i=1;i<=x;i++)
- {
- if(x%i==0)
- dem++;
- }
- if(dem==2)
- return 1;
- return 0;
- }
- // tinh tong
- long tinhNT(int y)
- {
- long s=0;
- int a;
- while(y!=0)
- {
- a=y%10;
- if(NT(a)==1)
- {
- s=s+a;
- }
- y=y/10;
- }
- return s;
- }
- void main()
- {
- int n;
- scanf("%d",&n);
- printf("%ld",tinhNT(n));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement