Computer Programming Contest Preparation

ToolBox - Source for: 102/10222/a.c



/home/toolbox/public_html/solutions/102/10222/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 257
   16 
   17 /*
   18  *  Author:
   19  *    Date:
   20  * Purpose:
   21  * Problem:
   22  */
   23 
   24 /*
   25  * This template reads lines of data at a time until end of file.
   26  */
   27 
   28 char line[MAX_LINE];
   29 
   30 void process(char x)
   31 {
   32     /* FUNCTION process */
   33     switch (x)
   34         {
   35         /* switch */
   36         case ' ':
   37             printf(" ");
   38             break;
   39         case '2':
   40             printf("'");
   41             break;
   42         case '3':
   43             printf("1");
   44             break;
   45         case '4':
   46             printf("2");
   47             break;
   48         case '5':
   49             printf("3");
   50             break;
   51         case '6':
   52             printf("4");
   53             break;
   54         case '7':
   55             printf("5");
   56             break;
   57         case '8':
   58             printf("6");
   59             break;
   60         case '9':
   61             printf("7");
   62             break;
   63         case '0':
   64             printf("8");
   65             break;
   66         case '-':
   67             printf("9");
   68             break;
   69         case '=':
   70             printf("0");
   71             break;
   72         case 'e':
   73             printf("q");
   74             break;
   75         case 'r':
   76             printf("w");
   77             break;
   78         case 't':
   79             printf("e");
   80             break;
   81         case 'y':
   82             printf("r");
   83             break;
   84         case 'u':
   85             printf("t");
   86             break;
   87         case 'i':
   88             printf("y");
   89             break;
   90         case 'o':
   91             printf("u");
   92             break;
   93         case 'p':
   94             printf("i");
   95             break;
   96         case '[':
   97             printf("o");
   98             break;
   99         case ']':
  100             printf("p");
  101             break;
  102         case '\\':
  103             printf("[");
  104             break;
  105         case 'd':
  106             printf("a");
  107             break;
  108         case 'f':
  109             printf("s");
  110             break;
  111         case 'g':
  112             printf("d");
  113             break;
  114         case 'h':
  115             printf("f");
  116             break;
  117         case 'j':
  118             printf("g");
  119             break;
  120         case 'k':
  121             printf("h");
  122             break;
  123         case 'l':
  124             printf("j");
  125             break;
  126         case ';':
  127             printf("k");
  128             break;
  129         case '\'':
  130             printf("l");
  131             break;
  132         case 'c':
  133             printf("z");
  134             break;
  135         case 'v':
  136             printf("x");
  137             break;
  138         case 'b':
  139             printf("c");
  140             break;
  141         case 'n':
  142             printf("v");
  143             break;
  144         case 'm':
  145             printf("b");
  146             break;
  147         case ',':
  148             printf("n");
  149             break;
  150         case '.':
  151             printf("m");
  152             break;
  153         case '/':
  154             printf(",");
  155             break;
  156         default:
  157             printf("XXXXXXX");
  158         } /* switch */
  159 } /* FUNCTION process */
  160 
  161 int main()
  162 {
  163     /* main */
  164     int moreToDo;
  165     char c;
  166 
  167     c = fgetc(stdin);
  168     while (( c != EOF) && (c != '\n' ))
  169         {
  170             /* while */
  171             process(tolower(c));
  172             c = fgetc(stdin);
  173         } /* while */
  174     printf("\n");
  175 
  176     return EXIT_SUCCESS;
  177 } /* main */
  178