Computer Programming Contest Preparation

ToolBox - Source for: 101/10110/j.c



/home/toolbox/public_html/solutions/101/10110/j.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: 2015-02-03
   18  * Purpose: fun
   19  * Problem: 10110
   20  */
   21 
   22 /*
   23  * This template reads data until a terminating value is reached.
   24  */
   25 
   26 unsigned int num;
   27 
   28 void init()
   29 {
   30     /* FUNCTION init */
   31 } /* FUNCTION init */
   32 
   33 void dump()
   34 {
   35     /* FUNCTION dump */
   36 } /* FUNCTION dump */
   37 
   38 int getInput()
   39 {
   40     /* FUNCTION getInput */
   41     int dataReadFlag;
   42 
   43     scanf(" %d ", &num);
   44     dataReadFlag = (0 != num);
   45     return (dataReadFlag);
   46 } /* FUNCTION getInput */
   47 
   48 void process()
   49 {
   50     /* FUNCTION process */
   51     unsigned int t;
   52 
   53     t = sqrt(num);
   54     if ((t*t) == num)
   55         {
   56             /* perfect square, light will be on */
   57             printf("yes\n");
   58         } /* perfect square, light will be on */
   59     else
   60         {
   61             /* light off */
   62             printf("no\n");
   63         } /* light off */
   64 } /* FUNCTION process */
   65 
   66 int main()
   67 {
   68     /* main */
   69     int moreToDo;
   70 
   71     init();
   72     moreToDo = getInput();
   73     while (moreToDo)
   74         {
   75             /* while */
   76             process();
   77             moreToDo = getInput();
   78         } /* while */
   79 
   80     return EXIT_SUCCESS;
   81 } /* main */
   82