Computer Programming Contest Preparation

ToolBox - Source for: 3/300/x.c



/home/toolbox/public_html/solutions/3/300/x.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:
   20  * Purpose: fun
   21  * Problem:
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 int numberOfTimes;
   29 char word[10];
   30 
   31 void init()
   32 {
   33     /* FUNCTION init */
   34     scanf("%d ", &numberOfTimes);
   35 } /* FUNCTION init */
   36 
   37 void dump()
   38 {
   39     /* FUNCTION dump */
   40 } /* FUNCTION dump */
   41 
   42 void getInput()
   43 {
   44     /* FUNCTION getInput */
   45     scanf("%s ", word);
   46 } /* FUNCTION getInput */
   47 
   48 void process()
   49 {
   50     /* FUNCTION process */
   51     int tot;
   52     int sln;
   53     int i;
   54 
   55     tot = 0;
   56     sln = strlen(word);
   57     for (i=0; i<sln; i++)
   58         {
   59             /* for */
   60             tot = tot + word[i];
   61         } /* for */
   62     printf("%s %d\n", word, tot);
   63 } /* FUNCTION process */
   64 
   65 int main()
   66 {
   67     /* main */
   68     int i;
   69 
   70     init();
   71     for (i=0; i<numberOfTimes; i++)
   72         {
   73             /* while */
   74             getInput();
   75             process();
   76         } /* while */
   77 
   78     return EXIT_SUCCESS;
   79 } /* main */
   80 
   81