Computer Programming Contest Preparation

ToolBox - Source for: 107/10730/a.c



/home/toolbox/public_html/solutions/107/10730/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: 2020-04-07
   18  * Purpose: fun
   19  * Problem: 10730 - Antiarithmetic
   20  */
   21 
   22 /*
   23  * This template reads data until a terminating value is reached.
   24  */
   25 
   26 #define MAX_NUM 10005
   27 
   28 int cnt;
   29 int num[MAX_NUM];
   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     int i;
   46 
   47     scanf(" %d: ", &cnt);
   48     DEBUG printf("%d\n", cnt);
   49     dataReadFlag = (0 != cnt);
   50     if (dataReadFlag)
   51         {
   52             /* load list */
   53             for (i=0; cnt>i; i++)
   54                 {
   55                     /* for */
   56                     scanf(" %d ", &num[i]);
   57                     DEBUG printf("num[%d]=%d\n", i,  num[i]);
   58                 } /* for */
   59         } /* load list */
   60 
   61     return (dataReadFlag);
   62 } /* FUNCTION getInput */
   63 
   64 void process()
   65 {
   66     /* FUNCTION process */
   67     int flag = FALSE;
   68     int i;
   69 
   70     for (i=2; (! flag) && (i<cnt); i++)
   71         {
   72             /* check each triple */
   73             flag = (num[i-2] < num[i-1]) && (num[i-1] < num[i]);
   74         } /* check each triple */
   75     if (flag)
   76         {
   77             printf("no\n");
   78         }
   79     else
   80         {
   81             printf("yes\n");
   82         }
   83 
   84 } /* FUNCTION process */
   85 
   86 int main()
   87 {
   88     /* main */
   89     int moreToDo;
   90 
   91     init();
   92     moreToDo = getInput();
   93     while (moreToDo)
   94         {
   95             /* while */
   96             process();
   97             moreToDo = getInput();
   98         } /* while */
   99 
  100     return EXIT_SUCCESS;
  101 } /* main */
  102