Computer Programming Contest Preparation

ToolBox - Source for: 116/11677/a.c



/home/toolbox/public_html/solutions/116/11677/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: 2017-01-22
   18  * Purpose: fun
   19  * Problem: 11677 Alarm Clock
   20  */
   21 
   22 /*
   23  * This template reads data until a terminating value is reached.
   24  */
   25 
   26 int h1;
   27 int m1;
   28 int h2;
   29 int m2;
   30 
   31 void init()
   32 {
   33     /* FUNCTION init */
   34 } /* FUNCTION init */
   35 
   36 void dump()
   37 {
   38     /* FUNCTION dump */
   39 } /* FUNCTION dump */
   40 
   41 int getInput()
   42 {
   43     /* FUNCTION getInput */
   44     int dataReadFlag;
   45 
   46     scanf(" %d %d %d %d ", &h1, &m1, &h2, &m2);
   47     dataReadFlag = ((0 != h1) || (0 != m1) || (0 != h2) || (0 != m2));
   48 
   49     return (dataReadFlag);
   50 } /* FUNCTION getInput */
   51 
   52 void process()
   53 {
   54     /* FUNCTION process */
   55     int sleep;
   56 
   57     m1 = m1 + (h1 * 60);
   58     m2 = m2 + (60 * (h2 + 24));
   59 
   60     sleep = (m2 - m1) % (24 * 60);
   61     printf("%d\n", sleep);
   62 
   63 } /* FUNCTION process */
   64 
   65 int main()
   66 {
   67     /* main */
   68     int moreToDo;
   69 
   70     init();
   71     moreToDo = getInput();
   72     while (moreToDo)
   73         {
   74             /* while */
   75             process();
   76             moreToDo = getInput();
   77         } /* while */
   78 
   79     return EXIT_SUCCESS;
   80 } /* main */
   81