home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_02 / schuyler.lst < prev    next >
File List  |  1993-01-04  |  1KB  |  39 lines

  1. short madaline_output(short outputs[],char choice,short A)
  2. {
  3.   int i,result,sum;
  4.  
  5.   /* use the AND method */
  6.   if (choice == 'a' || choice == 'A') {
  7.     result = 1;                     /* start out with TRUE result */
  8.     for (i = 0;i < A;i++) {
  9.       if (outputs[i] == -1) {       /* when first -1 found... */
  10.         result = -1;                /* set result */
  11.         break;                      /* and terminate */
  12.       }
  13.     }
  14.   }
  15.  
  16.   /* use the OR method */
  17.   if (choice == 'o' || choice == 'O') {
  18.     result = -1;                    /* start out with FALSE result */
  19.     for (i = 0;i < A;i++) {
  20.       if (outputs[i] == 1) {        /* when first 1 found... */
  21.         result = 1;                 /* set result */
  22.         break;                      /* and terminate */
  23.       }
  24.     }
  25.   }
  26.  
  27.   /* use the MAJORITY method */
  28.   if (choice == 'm' || choice == 'M') {
  29.     sum = 0;
  30.     for (i = 0;i < A;i++)
  31.       sum += outputs[i];            /* sum up all outputs */
  32.     if (sum > 0) result = 1;
  33.     else result = -1;
  34.   }
  35.  
  36.   return result;
  37. }
  38. /* ends madaline_output */
  39.