Computer Programming Contest Preparation

ToolBox - Source for: 4/458/a.c



/home/toolbox/public_html/solutions/4/458/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 
   15 #define MAX_LINE 200
   16 
   17 /*
   18  *  Author: Isaac Traxler
   19  *    Date: 2014-10-27
   20  * Purpose: fun
   21  * Problem: 683 - The Decoder
   22  */
   23 
   24 /*
   25  * This template reads data until a terminating value is reached.
   26  */
   27 
   28 char line[MAX_LINE];
   29 
   30 void init()
   31 {
   32     /* FUNCTION init */
   33 } /* FUNCTION init */
   34 
   35 void dump()
   36 {
   37     /* FUNCTION dump */
   38 } /* FUNCTION dump */
   39 
   40 int getInput()
   41 {
   42     /* FUNCTION getInput */
   43     int dataReadFlag;
   44 
   45     fgets(line, MAX_LINE, stdin);
   46     if (feof(stdin))
   47         dataReadFlag = FALSE;
   48     else
   49         {
   50             /* something to read */
   51             dataReadFlag = TRUE;
   52             line[strlen(line)-1] = 0;
   53         } /* something to read */
   54     return (dataReadFlag);
   55 } /* FUNCTION getInput */
   56 
   57 void process()
   58 {
   59     /* FUNCTION process */
   60     int i;
   61 
   62     for (i=0; i<strlen(line); i++)
   63         {
   64             /* process each char */
   65             line[i] = line[i] - 7;
   66         } /* process each char */
   67     printf("%s\n", line);
   68 } /* FUNCTION process */
   69 
   70 int main ()
   71 {
   72     /* main */
   73     int moreToDo;
   74 
   75     init();
   76     moreToDo = getInput();
   77     while (moreToDo)
   78         {
   79             /* while */
   80             process();
   81             moreToDo = getInput();
   82         } /* while */
   83 
   84     return EXIT_SUCCESS;
   85 } /* main */
   86