Guest User

Untitled

a guest
Dec 1st, 2020
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class Divine
  4. {
  5. std::int64_t _a;
  6. std::int64_t _b;
  7.  
  8. static int RetardedModulo(int a, int b)
  9. {
  10. if (b < a)
  11. {
  12. a = a + b;
  13. b = a - b;
  14. a = a - b;
  15. }
  16.  
  17. while (b >= a) { b -= a; }
  18. return b;
  19. }
  20.  
  21. public:
  22. Divine() = default;
  23. Divine(int a, int b) :
  24. _a{ a },
  25. _b{ b }{}
  26. static bool CanBeDivined(Divine&& object, bool(*DiviningFunc)(bool))
  27. {
  28. if (RetardedModulo(object._a, object._b) == 0)
  29. {
  30. return DiviningFunc(true) ? true : false;
  31. }
  32. else if (RetardedModulo(object._a, object._b) != 0)
  33. {
  34. return DiviningFunc(false) ? true : false;
  35. }
  36. else
  37. {
  38. return DiviningFunc(false) ? true : false;
  39. }
  40. }
  41. };
  42.  
  43. int main()
  44. {
  45. constexpr int a{ 10 };
  46. constexpr int b{ 2 };
  47. bool temporary=Divine().CanBeDivined(Divine(a, b),
  48. [](bool result)
  49. {
  50. return result;
  51. });
  52. if (temporary)
  53. {
  54. std::cout << "Can be divined\n";
  55. }
  56. else
  57. {
  58. std::cout << "Can not be divined\n";
  59. }
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment