Advertisement
haunted_mind

add1

Dec 8th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #pragma hdrstop
  2. #pragma argsused
  3.  
  4. #ifdef _WIN32
  5. #include <tchar.h>
  6. #else
  7. typedef char _TCHAR;
  8. #define _tmain main
  9. #endif
  10.  
  11. #include <stdio.h>
  12. #include <iostream>
  13. #include <conio.h>
  14.  
  15. using namespace std;
  16.  
  17. bool checkForfive(int x,int num, int z)
  18. {
  19. int y=1+x;
  20. while(y>x)
  21. {
  22. y=x;
  23. if (x&1) {
  24. x = x>>1;x+=z;
  25. }
  26. else x=x>>1;
  27. }
  28. while (x>0)
  29. {
  30. x-=num;
  31. }
  32. if(x==0) return 1;
  33. else return 0;
  34. }
  35.  
  36. int _tmain(int argc, _TCHAR* argv[])
  37. {
  38. int x;
  39. cin >> x;
  40. cout <<"Answer in boolean algebra if "<<x<<" is divided by 5 : "<<checkForfive(x,5,8)<<endl;
  41. cout <<"Answer in boolean algebra if "<<x<<" is divided by 29 : "<<checkForfive(x,29,15)<<endl;
  42. cout <<"Answer in boolean algebra if "<<x<<" is divided by 223 : "<<checkForfive(x,223,112)<<endl;
  43. getch();
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement