Advertisement
nguyenhappy92

số nguyên dương chia hết cho 3

Oct 16th, 2015
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. // Nhap vao moot so xac dinh so do chia het cho 3 hay ko
  2. // Khai bao ham thu vien neu co
  3. #include<stdio.h>
  4. #include<conio.h>
  5.  
  6. void main()
  7. {
  8. long n;
  9. scanf("%ld",&n);
  10. long m=n;
  11. long a;
  12. long s=0;
  13. while(n!=0)
  14. {
  15. a=n%10;
  16. s=s+a;
  17. n=n/10;
  18. }
  19. if(s%3==0)
  20. {
  21. printf("%ld chia het cho 3",m);
  22. }
  23. else
  24. {
  25. printf("%ld khong chia het cho 3",m);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement