Computer Programming Contest Preparation

ToolBox - Source for: 119/11942/a.c



/home/toolbox/public_html/solutions/119/11942/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 <stdlib.h>
    7 #include <math.h>
    8 #include <stdint.h>
    9 #include <ctype.h>
   10 
   11 #define TRUE  (1 == 1)
   12 #define FALSE (1 != 1)
   13 
   14 #define DEBUG if (FALSE)
   15 
   16 /* fprintf(stderr, "functionName: message", varslist); */
   17 
   18 /*
   19  *  Author: Isaac Traxler
   20  *    Date: 2021-09-02
   21  * Purpose: fun
   22  * Problem: 11942 - Lumberjack Sequencing
   23  */
   24 
   25 /*
   26  * This template reads data a specified number of times.
   27  */
   28 
   29 #define TERMS 10
   30 
   31 int numberOfTimes;
   32 int lj[TERMS];
   33 
   34 void init()
   35 {
   36     /* FUNCTION init */
   37     scanf("%d ", &numberOfTimes);
   38 } /* FUNCTION init */
   39 
   40 void dump()
   41 {
   42     /* FUNCTION dump */
   43 } /* FUNCTION dump */
   44 
   45 void getInput()
   46 {
   47     /* FUNCTION getInput */
   48     int i;
   49 
   50     for (i=0; TERMS>i; i++)
   51         {
   52             /* for */
   53             scanf(" %d ", &lj[i]);
   54         } /* for */
   55 } /* FUNCTION getInput */
   56 
   57 void process()
   58 {
   59     /* FUNCTION process */
   60     int i;
   61 
   62     if ((lj[0] > lj[1]) && (lj[1] > lj[2]) && (lj[2] > lj[3]) &&
   63             (lj[3] > lj[4]) && (lj[4] > lj[5]) && (lj[5] > lj[6]) &&
   64             (lj[6] > lj[7]) && (lj[7] > lj[8]) && (lj[8] > lj[9]))
   65         {
   66             /* then descending */
   67             printf("Ordered\n");
   68         } /* then descending */
   69     else if ((lj[0] < lj[1]) && (lj[1] < lj[2]) && (lj[2] < lj[3]) &&
   70              (lj[3] < lj[4]) && (lj[4] < lj[5]) && (lj[5] < lj[6]) &&
   71              (lj[6] < lj[7]) && (lj[7] < lj[8]) && (lj[8] < lj[9]))
   72         {
   73             /* then ascending */
   74             printf("Ordered\n");
   75         } /* then ascending */
   76     else
   77         {
   78             /* tie */
   79             printf("Unordered\n");
   80         } /* tie */
   81 } /* FUNCTION process */
   82 
   83 int main()
   84 {
   85     /* main */
   86     int i;
   87 
   88     init();
   89     printf("Lumberjacks:\n");
   90     for (i=0; i<numberOfTimes; i++)
   91         {
   92             /* while */
   93             getInput();
   94             process();
   95         } /* while */
   96 
   97     return EXIT_SUCCESS;
   98 } /* main */
   99 
  100