Computer Programming Contest Preparation

ToolBox - Source for: 102/10226/b.c



/home/toolbox/public_html/solutions/102/10226/b.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: 2018-11-05
   20  * Purpose: fun
   21  * Problem: 10226
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 #define MAX_LENGTH 36
   29 #define MAX_LENGTH_MINUS_1 35
   30 #define TREE_MAX 10002
   31 
   32 typedef struct TREE_STRUCT
   33 {
   34     /* struct TREE_STRUCT */
   35     char name[MAX_LENGTH];
   36     int count;
   37 } /* struct TREE_STRUCT */
   38 TREE_STRUCT;
   39 
   40 
   41 int numberOfTimes;
   42 char buf[MAX_LENGTH];
   43 TREE_STRUCT trees[TREE_MAX];
   44 int treeCnt;
   45 
   46 void init()
   47 {
   48     /* FUNCTION init */
   49     scanf("%d ", &numberOfTimes);
   50 } /* FUNCTION init */
   51 
   52 void dump()
   53 {
   54     /* FUNCTION dump */
   55 } /* FUNCTION dump */
   56 
   57 void getInput()
   58 {
   59     /* FUNCTION getInput */
   60     char * tmp;
   61 
   62     treeCnt = 0;
   63     buf[0] = 'a';
   64     tmp = fgets(trees[treeCnt].name, MAX_LENGTH_MINUS_1, stdin);
   65     if (NULL == tmp)
   66         {
   67             buf[0] = 0;
   68         }
   69     while (33 < buf[0])
   70         {
   71             /* read another line */
   72             trees[treeCnt].count = 1;
   73             strcpy(trees[treeCnt].name, buf);
   74             treeCnt++;
   75             tmp = fgets(buf, MAX_LENGTH_MINUS_1, stdin);
   76             if (NULL == tmp)
   77                 {
   78                     buf[0] = 0;
   79                 }
   80         } /* read another line */
   81     printf("Lines read: %d\n", treeCnt);
   82 } /* FUNCTION getInput */
   83 
   84 void process()
   85 {
   86     /* FUNCTION process */
   87 } /* FUNCTION process */
   88 
   89 int main()
   90 {
   91     /* main */
   92     int i;
   93 
   94     init();
   95     for (i=0; i<numberOfTimes; i++)
   96         {
   97             /* while */
   98             getInput();
   99             process();
  100         } /* while */
  101 
  102     return EXIT_SUCCESS;
  103 } /* main */
  104 
  105