Computer Programming Contest Preparation

ToolBox - Source for: 127/12764/a.c



/home/toolbox/public_html/solutions/127/12764/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 <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-09-29
   20  * Purpose: fun
   21  * Problem: 12764
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 #define MAX_DIGITS 73
   29 
   30 int numberOfTimes;
   31 char buff[MAX_DIGITS];
   32 int digits[MAX_DIGITS];
   33 int cnt;
   34 char ec[3][50] =
   35 {
   36     /* - 0-|-1-|-2-|-3-|-4-|- 5-|- 6-|- 7-|-8-|-9-| */
   37     "\\ /  o          _o_ \\o/ \\o_ \\o/      o  ",
   38     /* -0-|-1- |-2-|-3-|-4-|-5-|- 6-|- 7-|-8-|-9-| */
   39     " |  /|\\          |   |  \\|  \\|/  __o( ) ",
   40     /* -0- |-1- |-2- |- 3- |-4- |-5- |-6-|-7-|-8-|-9-| */
   41     "/o\\ / \\ __\\o\\_\\o/ \\ / \\  |      /  |/ \\ "
   42 };
   43 int count;
   44 
   45 
   46 void init()
   47 {
   48     /* FUNCTION init */
   49     scanf("%d ", &numberOfTimes);
   50 
   51 } /* FUNCTION init */
   52 
   53 void printEmoticon(int row, int digit)
   54 {
   55     /* FUNCTION printEmoticon */
   56     int i;
   57 
   58     for (i=0; i<4; i++)
   59         {
   60             /* for */
   61             printf("%c", ec[row][digit*4+i]);
   62         } /* for */
   63 
   64 } /* FUNCTION printEmoticon */
   65 
   66 void getInput()
   67 {
   68     /* FUNCTION getInput */
   69     int i;
   70 
   71     scanf(" %s ", buff);
   72     count = strlen(buff);
   73     for(i=0; i<count; i++)
   74         {
   75             /* for each digit */
   76             digits[i] = buff[i] - '0';
   77         } /* for each digit */
   78 } /* FUNCTION getInput */
   79 
   80 void process()
   81 {
   82     /* FUNCTION process */
   83     int i;
   84     int row;
   85 
   86     for (row=0; row<3; row++)
   87         {
   88             /* for each row */
   89             printEmoticon(row, digits[0]);
   90             for (i=1; i<count; i++)
   91                 {
   92                     /* print row */
   93                     printf(" ");
   94                     printEmoticon(row, digits[i]);
   95                 } /* print row */
   96             printf("\n");
   97         } /* for each row */
   98     printf("\n");
   99 
  100 } /* FUNCTION process */
  101 
  102 int main()
  103 {
  104     /* main */
  105     int i;
  106 
  107     init();
  108     for (i=0; i<numberOfTimes; i++)
  109         {
  110             /* while */
  111             getInput();
  112             process();
  113         } /* while */
  114 
  115     return EXIT_SUCCESS;
  116 } /* main */
  117 
  118