tom_burgess

gates.cpp

Jun 10th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. bool nand(bool a, bool b) {
  2.     return !(a&b);
  3. }
  4. bool not(bool a) {
  5.     return nand(a,a);
  6. }
  7. bool and(bool a, bool b) {
  8.     return nand(nand(a, b), nand(a, b));
  9. }
  10. bool or (bool a, bool b) {
  11.     return nand(not(a), and (not(a), not(b)));
  12. }
  13. bool xor(bool a, bool b) {
  14.     return and (nand(a, b), or (a, b));
  15. }
Advertisement
Add Comment
Please, Sign In to add comment