/home/toolbox/public_html/solutions/132/13275/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: 13275 - Leap Birthdays
23 */
24
25 /*
26 * This template reads data a specified number of times.
27 */
28
29 int numberOfTimes;
30 int day;
31 int month;
32 int year;
33 int query;
34
35 void init()
36 {
37 /* FUNCTION init */
38 scanf("%d ", &numberOfTimes);
39 } /* FUNCTION init */
40
41 void dump()
42 {
43 /* FUNCTION dump */
44 } /* FUNCTION dump */
45
46 void getInput()
47 {
48 /* FUNCTION getInput */
49 scanf(" %d %d %d %d ", &day, &month, &year, &query);
50 } /* FUNCTION getInput */
51
52 void process()
53 {
54 /* FUNCTION process */
55 int birthdays;
56 int i;
57
58 if ((2 != month) || (29 != day))
59 {
60 /* non-leap birthday */
61 birthdays = query - year;
62 } /* non-leap birthday */
63 else
64 {
65 /* leap-day birthday */
66 birthdays = 0;
67 for (i=year+1; query>=i; i++)
68 {
69 /* check year */
70 if (0 == (i % 400))
71 {
72 birthdays++;
73 }
74 else if (0 != (i % 100))
75 {
76 /* not a century */
77 if (0 == (i % 4))
78 {
79 birthdays++;
80 }
81 } /* not a century */
82 } /* check year */
83 } /* leap-day birthday */
84 printf("%d\n", birthdays);
85 } /* FUNCTION process */
86
87 int main()
88 {
89 /* main */
90 int i;
91
92 init();
93 for (i=1; i<=numberOfTimes; i++)
94 {
95 /* while */
96 getInput();
97 printf("Case %d: ", i);
98 process();
99 } /* while */
100
101 return EXIT_SUCCESS;
102 } /* main */
103
104