Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: C  |  size: 1.33 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>;
  2.  
  3. int und(int a, int b) {
  4.     if (a > 0 && b > 0) {
  5.           return 1;
  6.        } else if (a < 0 || b < 0) {
  7.                 return -1;
  8.                 } else {
  9.                        return 0;
  10.                        }
  11. }
  12.  
  13. int oder(int a, int b) {
  14.     if (a > 0 || b > 0) {
  15.           return 1;
  16.        } else if (a < 0 && b < 0) {
  17.                 return -1;
  18.                 } else {
  19.                        return 0;
  20.                        }
  21. }
  22.  
  23. int nicht(int a) {
  24.     return a * (-1);
  25. }
  26.  
  27. int main(int argc, char **argv) {
  28.     int test = 0;
  29.     test = und(-1,0);      
  30.     fprintf(stdout,"und(-1,0)=%d\n", test);
  31.     test = und(0,1);      
  32.         fprintf(stdout,"und(0,1)=%d\n", test);
  33.     test = und(1,1);      
  34.         fprintf(stdout,"und(1,1)=%d\n", test);
  35.        
  36.     test = oder(-1,0);      
  37.     fprintf(stdout,"oder(-1,0)=%d\n", test);
  38.     test = oder(0,1);      
  39.         fprintf(stdout,"oder(0,1)=%d\n", test);
  40.     test = oder(0,0);      
  41.         fprintf(stdout,"oder(1,1)=%d\n", test);
  42.                
  43.     test = nicht(0);      
  44.         fprintf(stdout,"nicht(0)=%d\n", test);
  45.     test = nicht(1);      
  46.         fprintf(stdout,"nicht(1)=%d\n", test);
  47.     test = nicht(-1);      
  48.         fprintf(stdout,"nicht(-1)=%d\n", test);
  49.                
  50.     test = oder(-1,und(nicht(0),1));      
  51.         fprintf(stdout,"oder(-1,und(nicht(0),1))=%d\n", test);
  52.                 getchar();
  53.      }