Computer Programming Contest Preparation

ToolBox - Source for: 117/11777/a.c



/home/toolbox/public_html/solutions/117/11777/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 
   10 #define TRUE  (1 == 1)
   11 #define FALSE (1 != 1)
   12 
   13 #define DEBUG if (FALSE)
   14 
   15 /* fprintf(stderr, "functionName: message", varslist); */
   16 
   17 /*
   18  *  Author: Isaac Traxler
   19  *    Date:
   20  * Purpose: fun
   21  * Problem:
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 int numberOfTimes;
   29 
   30 int t1, t2, fin, att, c1, c2, c3;
   31 
   32 int min(int a, int b)
   33 {
   34     /* FUNCTION min */
   35     int ret;
   36 
   37     if (a < b)
   38         {
   39             ret = a;
   40         }
   41     else
   42         {
   43             ret = b;
   44         }
   45     return ret;
   46 } /* FUNCTION min */
   47 
   48 void init()
   49 {
   50     /* FUNCTION init */
   51     scanf("%d ", &numberOfTimes);
   52 } /* FUNCTION init */
   53 
   54 void dump()
   55 {
   56     /* FUNCTION dump */
   57 } /* FUNCTION dump */
   58 
   59 void getInput()
   60 {
   61     /* FUNCTION getInput */
   62     scanf(" %d %d %d %d %d %d %d ", &t1, &t2, &fin, &att, &c1, &c2, &c3);
   63 } /* FUNCTION getInput */
   64 
   65 int sum(int a, int b, int c)
   66 {
   67     /* FUNCTION sum */
   68     int tot;
   69 
   70     tot = a + b + c - min(a, min(b, c));
   71     return tot;
   72 } /* FUNCTION sum */
   73 
   74 void process()
   75 {
   76     /* FUNCTION process */
   77     double c;
   78     double grade;
   79 
   80     c = sum(c1, c2, c3) / 2.0;
   81     grade = t1 + t2 + fin + att + c;
   82     if (grade >= 90.0)
   83         {
   84             printf("A\n");
   85         }
   86     else if (grade >= 80.0)
   87         {
   88             printf("B\n");
   89         }
   90     else if (grade >= 70.0)
   91         {
   92             printf("C\n");
   93         }
   94     else if (grade >= 60.0)
   95         {
   96             printf("D\n");
   97         }
   98     else
   99         {
  100             printf("F\n");
  101         }
  102 } /* FUNCTION process */
  103 
  104 int main()
  105 {
  106     /* main */
  107     int i;
  108 
  109     init();
  110     for (i=1; i<=numberOfTimes; i++)
  111         {
  112             /* while */
  113             getInput();
  114             printf("Case %d: ", i);
  115             process();
  116         } /* while */
  117 
  118     return EXIT_SUCCESS;
  119 } /* main */
  120 
  121