fork download
  1. #include <stdio.h>
  2. int main()
  3. {
  4. unsigned int a, b, c, d;
  5. unsigned int f;
  6.  
  7. printf(" bc \n");
  8. printf(" 00 01 11 10 \n");
  9. printf(" ______________\n");
  10.  
  11. for (a = 0; a < 2; a++) {
  12. printf("a=%u | ", a);
  13.  
  14. for (b = 0; b < 2; b++) {
  15. for (d = 0; d < 2; d++) {
  16.  
  17. // Gray code generation
  18. c = d ^ b;
  19.  
  20. // f = ab + b'c'
  21. f = (a & b) | ((~b & 1) & (~c & 1));
  22. f = f & 1;
  23.  
  24. printf("%u ", f);
  25. }
  26. }
  27. printf("\n");
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
         bc      
     00 01 11 10 
   ______________
a=0 | 1 0 0 0 
a=1 | 1 0 1 1