Computer Programming Contest Preparation

ToolBox - Source for: 3/394/a-input.c



/home/toolbox/public_html/solutions/3/394/a-input.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 #include <ctype.h>
   10 
   11 #define TRUE  (1 == 1)
   12 #define FALSE (1 != 1)
   13 
   14 #define DEBUG if (FALSE)
   15 
   16 /* fprintf(stderr, "functionName: message", varslist); */
   17 
   18 #define MAX_NAME_LENGTH 15
   19 #define MAX_NUMBER_DIMENSIONS 15
   20 #define MAX_ARRAYS 10000
   21 
   22 /*
   23  *  Author: Isaac Traxler
   24  *    Date: 2021-08-26
   25  * Purpose: fun
   26  * Problem: 394 - Mapmaker
   27  */
   28 
   29 
   30 /*
   31  * This template reads data a specified number of times.
   32  */
   33 
   34 typedef struct ARRAY_STRUCT
   35 {
   36     char name[MAX_NAME_LENGTH];
   37     int base;
   38     int size;
   39     int dimCnt;
   40     int frst[MAX_NUMBER_DIMENSIONS];
   41     int last[MAX_NUMBER_DIMENSIONS];
   42 } ARRAY_STRUCT;
   43 
   44 
   45 
   46 int N;
   47 int R;
   48 ARRAY_STRUCT a[MAX_ARRAYS];
   49 
   50 void init()
   51 {
   52     /* FUNCTION init */
   53     scanf(" %d %d ", &N, &R);
   54 } /* FUNCTION init */
   55 
   56 void dump()
   57 {
   58     /* FUNCTION dump */
   59     int i;
   60     int j;
   61 
   62     for (i=0; N>i; i++)
   63         {
   64             /* for each array */
   65             printf("%8d(%1d): %-11s[(%d..%d)", a[i].base, a[i].size, a[i].name, a[i].frst[1], a[i].last[1]);
   66             for (j=2; a[i].dimCnt>=j; j++)
   67                 {
   68                     /* for each additional dimension */
   69                     printf(", (%d..%d)", a[i].frst[j], a[i].last[j]);
   70                 } /* for each additional dimension */
   71             printf("]\n");
   72         } /* for each array */
   73 } /* FUNCTION dump */
   74 
   75 void getArrayDefinitions()
   76 {
   77     /* FUNCTION getArrayDefinitions */
   78     int i;
   79     int j;
   80 
   81     for (i=0; N>i; i++)
   82         {
   83             /* for each array definitions */
   84             scanf(" %s ", a[i].name);
   85             scanf(" %d ", &a[i].base);
   86             scanf(" %d ", &a[i].size);
   87             scanf(" %d ", &a[i].dimCnt);
   88             for (j=1; j<=a[i].dimCnt; j++)
   89                 {
   90                     /* for each dimension */
   91                     scanf(" %d %d ", &a[i].frst[j], &a[i].last[j]);
   92                 } /* for each dimension */
   93         } /* for each array definitions */
   94 } /* FUNCTION getArrayDefinitions */
   95 
   96 void getReference()
   97 {
   98     /* FUNCTION getReference */
   99 } /* FUNCTION getReference */
  100 
  101 void process()
  102 {
  103     /* FUNCTION process */
  104 } /* FUNCTION process */
  105 
  106 int main()
  107 {
  108     /* main */
  109     int i;
  110 
  111     init();
  112     getArrayDefinitions();
  113     dump();
  114     return 0;
  115     for (i=0; i<R; i++)
  116         {
  117             /* while */
  118             getReference();
  119             process();
  120         } /* while */
  121 
  122     return EXIT_SUCCESS;
  123 } /* main */
  124 
  125