Advertisement
Courbe_Impliquee

Кратность 3

Mar 1st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. // ConsoleApplication27.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "stdio.h"
  6. #include <iostream>
  7. #include <cmath>
  8. using namespace std;
  9. int sum(int a){
  10. int s=0;
  11. while (a != 0){
  12. s += a % 10;
  13. a /= 10;
  14. }
  15. return s;
  16. }
  17. int del3(int a){
  18. if (sum(a) % 3 == 0)
  19. return true;
  20. else return false;
  21. }
  22.  
  23. int _tmain(int argc, _TCHAR* argv[])
  24. {
  25. int n;
  26. cin >> n;
  27. if (del3(n))
  28. cout << "YES\n";
  29. else
  30. cout << "NO\n";
  31. system("pause");
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement