Computer Programming Contest Preparation

ToolBox - Source for: 118/11879/b.c



/home/toolbox/public_html/solutions/118/11879/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 #include <ctype.h>
   10 
   11 #define TRUE  (1 == 1)
   12 #define FALSE (1 != 1)
   13 
   14 #define DEBUG if (FALSE)
   15 
   16 #define MAX_LINE 257
   17 
   18 /*
   19  *  Author: Isaac Traxler
   20  *    Date: 2021-12-6
   21  * Purpose: fun
   22  * Problem: 11879 - Multiple of 17
   23  */
   24 
   25 /*
   26  * This template reads lines of data at a time until end of file.
   27  */
   28 
   29 char line[MAX_LINE];
   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     fgets(line, MAX_LINE, stdin);
   47     line[strlen(line)-1] = 0;
   48     dataReadFlag = strcmp(line, "0");
   49     return (dataReadFlag);
   50 } /* FUNCTION getInput */
   51 
   52 void process()
   53 {
   54     /* FUNCTION process */
   55     int t;
   56 
   57     t = 5 * (line[strlen(line)-1] - '0');
   58     printf("t %d\n", t);
   59     if ((17 == t) || (34 == t))
   60         {
   61             /* divisible by 17 */
   62             printf("1\n");
   63         } /* divisible by 17 */
   64     else
   65         {
   66             /* not divisible by 17 */
   67             printf("1\n");
   68         } /* not divisible by 17 */
   69 } /* FUNCTION process */
   70 
   71 int main()
   72 {
   73     /* main */
   74     int moreToDo;
   75 
   76     init();
   77     moreToDo = getInput();
   78     while (moreToDo)
   79         {
   80             /* while */
   81             process();
   82             moreToDo = getInput();
   83         } /* while */
   84 
   85     return EXIT_SUCCESS;
   86 } /* main */
   87