Computer Programming Contest Preparation

ToolBox - Source for: 105/10557/a.c



/home/toolbox/public_html/solutions/105/10557/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 <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 #define DEBUG1 if (FALSE)
   15 #define DEBUG2 if (FALSE)
   16 
   17 #define MAX_ROOMS 102
   18 
   19 
   20 /*
   21  *  Author:
   22  *    Date:
   23  * Purpose: practice
   24  * Problem: 10557
   25  */
   26 
   27 /*
   28  * This template reads data until a terminating value is reached.
   29  */
   30 
   31 typedef struct NAME
   32 {
   33     int energy;
   34     int cnt;
   35     int dest[MAX_ROOMS];
   36 } NAME;
   37 
   38 NAME rooms[MAX_ROOMS];
   39 
   40 int numRooms; /* number of rooms in this case */
   41 
   42 int init()
   43 {
   44     /* FUNCTION init */
   45 } /* FUNCTION init */
   46 
   47 int dump()
   48 {
   49     /* FUNCTION dump */
   50 } /* FUNCTION dump */
   51 
   52 int getInput()
   53 {
   54     /* FUNCTION getInput */
   55     int dataReadFlag;
   56     int i;
   57     int j;
   58 
   59     scanf(" %d ", &numRooms);
   60     if (-1 != numRooms)
   61         {
   62             /* data to read */
   63             dataReadFlag = TRUE;
   64             for (i=0; i<numRooms; i++)
   65                 {
   66                     /* for */
   67                     scanf(" %d ",&rooms[i].energy);
   68                     scanf(" %d ",&rooms[i].cnt);
   69                     for (j=0; j<rooms[i].cnt; j++)
   70                         {
   71                             /* for */
   72                             scanf(" %d ",&rooms[i].dest[j]);
   73                         } /* for */
   74                 } /* for */
   75         } /* data to read */
   76     else
   77         {
   78             dataReadFlag = FALSE;
   79         }
   80 
   81     return (dataReadFlag);
   82 } /* FUNCTION getInput */
   83 
   84 void process()
   85 {
   86     /* FUNCTION process */
   87 } /* FUNCTION process */
   88 
   89 int main ()
   90 {
   91     /* main */
   92     int moreToDo;
   93 
   94     init();
   95     moreToDo = getInput();
   96     while (moreToDo)
   97         {
   98             /* while */
   99             process();
  100             moreToDo = getInput();
  101         } /* while */
  102 
  103     return EXIT_SUCCESS;
  104 } /* main */
  105