Computer Programming Contest Preparation

ToolBox - Source for: 126/12696/a.c



/home/toolbox/public_html/solutions/126/12696/a.c
    1 #include <stdio.h>
    2 #include <string.h>
    3 #include <sys/types.h>
    4 #include <sys/stat.h>
    5 #include <fcntl.h>
    6 #include <stdlib.h>
    7 #include <math.h>
    8 #include <stdint.h>
    9 
   10 #define TRUE  (1 == 1)
   11 #define FALSE (1 != 1)
   12 
   13 #define DEBUG if (FALSE)
   14 
   15 /* fprintf(stderr, "functionName: message", varslist); */
   16 
   17 /*
   18  *  Author: Isaac Traxler
   19  *    Date: 2015-10-13
   20  * Purpose: fun
   21  * Problem: 12696 - Cabin Baggage
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 int numberOfTimes;
   29 double lngth;
   30 double wdth;
   31 double dpth;
   32 double wght;
   33 int allowed = 0;
   34 
   35 
   36 void init()
   37 {
   38     /* FUNCTION init */
   39     scanf("%d ", &numberOfTimes);
   40 } /* FUNCTION init */
   41 
   42 void dump()
   43 {
   44     /* FUNCTION dump */
   45 } /* FUNCTION dump */
   46 
   47 void getInput()
   48 {
   49     /* FUNCTION getInput */
   50     scanf(" %lf %lf %lf %lf ", &lngth, &wdth, &dpth, &wght);
   51 } /* FUNCTION getInput */
   52 
   53 void process()
   54 {
   55     /* FUNCTION process */
   56     int okay = 1;
   57 
   58     /* over weight */
   59     if (7 < wght)
   60         {
   61             okay = 0;
   62         }
   63     /* at least one side is to long and over total */
   64     if (((56 < lngth) || (45 < wdth) || (25 < dpth)) && ((125 < (lngth + wdth + dpth))))
   65         {
   66             okay = 0;
   67         }
   68     if (1 == okay)
   69         {
   70             allowed++;
   71         }
   72     printf("%d\n", okay);
   73 } /* FUNCTION process */
   74 
   75 int main()
   76 {
   77     /* main */
   78     int i;
   79 
   80     init();
   81     for (i=0; i<numberOfTimes; i++)
   82         {
   83             /* while */
   84             getInput();
   85             process();
   86         } /* while */
   87     printf("%d\n", allowed);
   88 
   89     return EXIT_SUCCESS;
   90 } /* main */
   91 
   92