Computer Programming Contest Preparation

ToolBox - Source for: 4/482/b.c



/home/toolbox/public_html/solutions/4/482/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 <stdint.h>
    7 #include <math.h>
    8 #include <stdlib.h>
    9 
   10 #define TRUE  (1 == 1)
   11 #define FALSE (1 != 1)
   12 
   13 #define DEBUG if (FALSE)
   14 
   15 
   16 /*
   17  *  Author:
   18  *    Date:
   19  * Purpose:
   20  * Problem:
   21  */
   22 
   23 /*
   24  * This template reads lines of data at a time until end of file.
   25  */
   26 
   27 #define MAX_LINE 257
   28 #define MAX_NUMBERS 128
   29 
   30 typedef struct RECORD_STRUCT
   31 {
   32     /* struct RECORD_STRUCT */
   33     int  index;
   34     char value[MAX_LINE];
   35 } /* struct RECORD_STRUCT */
   36 RECORD_STRUCT;
   37 
   38 
   39 int  numCases;
   40 char line[MAX_LINE];
   41 RECORD_STRUCT numbers[MAX_NUMBERS];
   42 int  numCnt;
   43 
   44 
   45 void init()
   46 {
   47     /* FUNCTION init */
   48     scanf(" %d ", &numCases);
   49     printf("numCases = %d\n", numCases);
   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     char *token;
   62     int cnt;
   63     int i;
   64 
   65     /* skip end of line */
   66     // fgets(line, MAX_LINE, stdin);
   67     /* skip blank line */
   68     // fgets(line, MAX_LINE, stdin);
   69     /* get first line of input */
   70     fgets(line, MAX_LINE, stdin);
   71     line[strlen(line) - 1] = 0;
   72     /* extract the numbers */
   73     tmp = line;
   74     numCnt = 0;
   75     token = strtok(tmp, " ");
   76     while (NULL != token)
   77         {
   78             /* while something left in string */
   79             sscanf(token, " %d ", numbers[numCnt].index);
   80             numCnt++;
   81             token = strtok(NULL, " ");
   82         } /* while something left in string */
   83     /* load values */
   84     for (i=0; i<numCnt; i++)
   85         {
   86             /* for */
   87             scanf(" %s ", values);
   88             DEBUG printf("%d: %s\n", i, values[i]);
   89         } /* for */
   90 
   91 } /* FUNCTION getInput */
   92 
   93 void process()
   94 {
   95     /* FUNCTION process */
   96 } /* FUNCTION process */
   97 
   98 int main()
   99 {
  100     /* main */
  101     int i;
  102 
  103     init();
  104     for (i=0; i<numCases; i++)
  105         {
  106             /* for */
  107             getInput();
  108             process();
  109         } /* for */
  110 
  111     return EXIT_SUCCESS;
  112 } /* main */
  113