/home/toolbox/public_html/solutions/124/12403/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 #define MAX_LINE 80
16
17
18
19 /* fprintf(stderr, "functionName: message", varslist); */
20
21 /*
22 * Author: Isaac Traxler
23 * Date: 2014-10-26
24 * Purpose: UVA Hack-a-thon
25 * Problem: 12403 - Save setu
26 */
27
28 /*
29 * This template reads data a specified number of times.
30 */
31
32 int numberOfTimes;
33 char line[MAX_LINE];
34 int total = 0;
35
36 void init()
37 {
38 /* FUNCTION init */
39 scanf("%d ", &numberOfTimes);
40 } /* FUNCTION init */
41
42 void dump()
43 {
44 /* FUNCTION dump */
45 } /* FUNCTION dump */
46
47 void getInput()
48 {
49 /* FUNCTION getInput */
50
51 scanf(" %s ", line);
52 } /* FUNCTION getInput */
53
54 void process()
55 {
56 /* FUNCTION process */
57 int amt;
58 if (0 == strcmp("donate", line))
59 {
60 /* get amount */
61 scanf(" %d ", &amt);
62 total = total + amt;
63 } /* get amount */
64 else
65 {
66 /* report */
67 printf("%d\n", total);
68 } /* report */
69 } /* FUNCTION process */
70
71 int main ()
72 {
73 /* main */
74 int i;
75
76 init();
77 for (i=0; i<numberOfTimes; i++)
78 {
79 /* while */
80 getInput();
81 process();
82 } /* while */
83
84 return EXIT_SUCCESS;
85 } /* main */
86
87