Computer Programming Contest Preparation

ToolBox - Source for: 127/12705/b.c



/home/toolbox/public_html/solutions/127/12705/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: 2015-10-01
   20  * Purpose: fun
   21  * Problem: 12705 - Breaking Board
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 #define MAX_LINE_LENGTH 105
   29 /* digits 48-57
   30    upper 65-90 */
   31 #define SPACE 32
   32 #define DIGIT_START 48
   33 #define DIGIT_STOP 58
   34 #define UPPER_START 65
   35 #define UPPER_STOP 91
   36 
   37 int numberOfTimes;
   38 int board[36] =
   39 {
   40     2,
   41     3,   3,
   42     4,   4,  4,
   43     5,   5,  5,  5,
   44     6,   6,  6,  6,  6,
   45     7,   7,  7,  7,  7,  7,
   46     8,   8,  8,  8,  8,
   47     9,   9,  9,  9,
   48     10, 10, 10,
   49     11, 11,
   50     12
   51 };
   52 int occurences[255];
   53 char buff[MAX_LINE_LENGTH];
   54 
   55 void init()
   56 {
   57     /* FUNCTION init */
   58     scanf("%d ", &numberOfTimes);
   59 } /* FUNCTION init */
   60 
   61 void dump()
   62 {
   63     /* FUNCTION dump */
   64 } /* FUNCTION dump */
   65 
   66 int compare(const void *a, const void *b)
   67 {
   68     /* FUNCTION compare */
   69     return ( *(int*)a - *(int*)b );
   70 } /* FUNCTION compare */
   71 
   72 void getInput()
   73 {
   74     /* FUNCTION getInput */
   75     int i;
   76 
   77     fgets(buff, sizeof(buff), stdin);
   78     buff[strlen(buff) - 1] = '\0';
   79     occurrences[SPACE] = 0;
   80     for (i=DIGIT_START; i<DIGIT_STOP; i++)
   81         {
   82             occurences[i] = 0;
   83         }
   84     for (i=UPPER_START; i<UPPER_STOP; i++)
   85         {
   86             occurences[i] = 0;
   87         }
   88     for (i=0; i<strlen(buff); i++)
   89         {
   90             /* for each character */
   91             occurrences[buff[i]]++;
   92         } /* for each character */
   93 } /* FUNCTION getInput */
   94 
   95 void process()
   96 {
   97     /* FUNCTION process */
   98 } /* FUNCTION process */
   99 
  100 int main()
  101 {
  102     /* main */
  103     int i;
  104 
  105     init();
  106     for (i=0; i<numberOfTimes; i++)
  107         {
  108             /* while */
  109             getInput();
  110             process();
  111         } /* while */
  112 
  113     return EXIT_SUCCESS;
  114 } /* main */
  115 
  116