Computer Programming Contest Preparation

ToolBox - Source for: 127/12798/a.c



/home/toolbox/public_html/solutions/127/12798/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 /*
   16  *  Author: Isaac Traxler
   17  *    Date: 2015-09-29
   18  * Purpose: fun
   19  * Problem: 12798
   20  */
   21 
   22 /*
   23  * This template reads data until a terminating value is reached.
   24  */
   25 
   26 int players;
   27 int games;
   28 
   29 void init()
   30 {
   31     /* FUNCTION init */
   32 } /* FUNCTION init */
   33 
   34 void dump()
   35 {
   36     /* FUNCTION dump */
   37 } /* FUNCTION dump */
   38 
   39 int getInput()
   40 {
   41     /* FUNCTION getInput */
   42     int dataReadFlag;
   43 
   44     dataReadFlag = ((2 == scanf(" %d %d ", &players, &games)));
   45     return (dataReadFlag);
   46 } /* FUNCTION getInput */
   47 
   48 void process()
   49 {
   50     /* FUNCTION process */
   51     int cnt = 0;
   52     int flag;
   53     int i;
   54     int j;
   55     int score;
   56 
   57     for (i=0; i<players; i++)
   58         {
   59             /* for each player */
   60             flag = TRUE;
   61             for (j=0; j<games; j++)
   62                 {
   63                     /* for each game */
   64                     scanf(" %d ", &score);
   65                     flag = flag && (0 != score);
   66                 } /* for each game */
   67             if (flag)
   68                 {
   69                     cnt++;
   70                 }
   71         } /* for each player */
   72     printf("%d\n", cnt);
   73 } /* FUNCTION process */
   74 
   75 int main()
   76 {
   77     /* main */
   78     int moreToDo;
   79 
   80     init();
   81     moreToDo = getInput();
   82     while (moreToDo)
   83         {
   84             /* while */
   85             process();
   86             moreToDo = getInput();
   87         } /* while */
   88 
   89     return EXIT_SUCCESS;
   90 } /* main */
   91