Computer Programming Contest Preparation

ToolBox - Source for: 102/10220/test.c



/home/toolbox/public_html/solutions/102/10220/test.c
    1 #include <stdio.h>
    2 
    3 #define TRUE  (1 == 1)
    4 #define FALSE (1 != 1)
    5 
    6 int sum = 0;
    7 int curr;
    8 char c;
    9 int getInput()
   10 {
   11     // BEGIN FUNCTION getInput
   12     int returned;
   13     returned = scanf("%c", &c);
   14     if(c-'0' < 10 && c-'0' > -1)
   15         {
   16             sum += c-'0';
   17             return 1;
   18         }
   19     else
   20         return 0;
   21 } // END FUNCTION getInput
   22 
   23 int process()
   24 {
   25     // BEGIN FUNCTION process
   26     printf(" sum: %d\n", sum);
   27     return 0;
   28 } // END FUNCTION process
   29 
   30 int main ()
   31 {
   32     // main
   33     int moreToDo;
   34 
   35     moreToDo = getInput();
   36     while (moreToDo)
   37         {
   38             // while
   39             //    process();
   40             moreToDo = getInput();
   41         } // while
   42     printf(" sum: %d\n", sum);
   43 
   44     return 1;
   45 } // main
   46