Computer Programming Contest Preparation

ToolBox - Source for: 125/12578/a.c



/home/toolbox/public_html/solutions/125/12578/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-12-16
   21  * Purpose: fun
   22  * Problem: 12578 - 10:6:2
   23  */
   24 
   25 /*
   26  * This template reads data a specified number of times.
   27  */
   28 
   29 #define PI 3.14159265359l
   30 int numberOfTimes;
   31 int length;
   32 double radius;
   33 double areaCircle;
   34 double areaFlag;
   35 double areaGreen;
   36 
   37 void init()
   38 {
   39     /* FUNCTION init */
   40     scanf("%d ", &numberOfTimes);
   41 } /* FUNCTION init */
   42 
   43 void dump()
   44 {
   45     /* FUNCTION dump */
   46 } /* FUNCTION dump */
   47 
   48 void getInput()
   49 {
   50     /* FUNCTION getInput */
   51     scanf(" %d ", &length);
   52 } /* FUNCTION getInput */
   53 
   54 void process()
   55 {
   56     /* FUNCTION process */
   57     areaFlag = length * length * 0.6l;
   58     radius = length / 5.0l;
   59     areaCircle = PI * radius * radius;
   60     areaGreen = areaFlag - areaCircle;
   61     printf("%.2lf %.2lf\n", areaCircle, areaGreen);
   62 } /* FUNCTION process */
   63 
   64 int main()
   65 {
   66     /* main */
   67     int i;
   68 
   69     init();
   70     for (i=0; i<numberOfTimes; i++)
   71         {
   72             /* while */
   73             getInput();
   74             process();
   75         } /* while */
   76 
   77     return EXIT_SUCCESS;
   78 } /* main */
   79 
   80