Computer Programming Contest Preparation

ToolBox - Source for: 103/10300/a.c



/home/toolbox/public_html/solutions/103/10300/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: 2014-10-28
   20  * Purpose: fun
   21  * Problem: 10300 - Ecological Premium
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 int numberOfTimes;
   29 int numberOfFarmers;
   30 
   31 void init()
   32 {
   33     /* FUNCTION init */
   34     scanf("%d ", &numberOfTimes);
   35 } /* FUNCTION init */
   36 
   37 void dump()
   38 {
   39     /* FUNCTION dump */
   40 } /* FUNCTION dump */
   41 
   42 void getInput()
   43 {
   44     /* FUNCTION getInput */
   45     scanf(" %d ", &numberOfFarmers);
   46 } /* FUNCTION getInput */
   47 
   48 void process()
   49 {
   50     /* FUNCTION process */
   51     int i;
   52     int tot = 0;
   53     int area;
   54     int animals;
   55     int eco;
   56 
   57     for (i=0; i<numberOfFarmers; i++)
   58         {
   59             /* process each farmer */
   60             scanf(" %d %d %d ", &area, &animals, &eco);
   61             DEBUG printf("%d %d \n", area, eco);
   62             tot = tot + area * eco;
   63         } /* process each farmer */
   64     printf("%d\n", tot);
   65 } /* FUNCTION process */
   66 
   67 int main ()
   68 {
   69     /* main */
   70     int i;
   71 
   72     init();
   73     for (i=0; i<numberOfTimes; i++)
   74         {
   75             /* while */
   76             getInput();
   77             process();
   78         } /* while */
   79 
   80     return EXIT_SUCCESS;
   81 } /* main */
   82 
   83