Computer Programming Contest Preparation

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



/home/toolbox/public_html/solutions/102/10222/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 <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         case 'E':
  157             printf("Q");
  158             break;
  159         case 'R':
  160             printf("W");
  161             break;
  162         case 'T':
  163             printf("E");
  164             break;
  165         case 'Y':
  166             printf("R");
  167             break;
  168         case 'U':
  169             printf("T");
  170             break;
  171         case 'I':
  172             printf("Y");
  173             break;
  174         case 'O':
  175             printf("U");
  176             break;
  177         case 'P':
  178             printf("I");
  179             break;
  180         case '{':
  181             printf("O");
  182             break;
  183         case '}':
  184             printf("P");
  185             break;
  186         case '|':
  187             printf("{");
  188             break;
  189         case 'D':
  190             printf("A");
  191             break;
  192         case 'F':
  193             printf("S");
  194             break;
  195         case 'G':
  196             printf("D");
  197             break;
  198         case 'H':
  199             printf("F");
  200             break;
  201         case 'J':
  202             printf("G");
  203             break;
  204         case 'K':
  205             printf("H");
  206             break;
  207         case 'L':
  208             printf("J");
  209             break;
  210         case ':':
  211             printf("K");
  212             break;
  213         case '"':
  214             printf("L");
  215             break;
  216         case 'C':
  217             printf("Z");
  218             break;
  219         case 'V':
  220             printf("X");
  221             break;
  222         case 'B':
  223             printf("C");
  224             break;
  225         case 'N':
  226             printf("V");
  227             break;
  228         case 'M':
  229             printf("B");
  230             break;
  231         case '<':
  232             printf("N");
  233             break;
  234         case '>':
  235             printf("M");
  236             break;
  237         case '?':
  238             printf("<");
  239             break;
  240         default:
  241             printf("XXXXXXX");
  242         } /* switch */
  243 } /* FUNCTION process */
  244 
  245 int main()
  246 {
  247     /* main */
  248     int moreToDo;
  249     char c;
  250 
  251     c = fgetc(stdin);
  252     while (( c != EOF) && (c != '\n' ))
  253         {
  254             /* while */
  255             process(c);
  256             c = fgetc(stdin);
  257         } /* while */
  258     printf("\n");
  259 
  260     return EXIT_SUCCESS;
  261 } /* main */
  262