/home/toolbox/public_html/solutions/120/12019/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: 2016-01-27
20 * Purpose: fun
21 * Problem: 12019 - Doom's Day Algorithm
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 int numberOfTimes;
29
30 char days[7][10] = { "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday" };
31 /* put a dummy month in so month 1/january corresponds to 1th inde */
32 int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 21 };
33 int mnth;
34 int day;
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 scanf(" %d %d ", &mnth, &day);
51 } /* FUNCTION getInput */
52
53 void process()
54 {
55 /* FUNCTION process */
56 int tot = 0;
57 int i;
58
59 for (i=1; i<mnth; i++)
60 {
61 /* cover all months before current */
62 tot = tot + months[i];
63 } /* cover all months before current */
64 tot = (tot + day) % 7;
65 printf("%s\n", days[tot]);
66 } /* FUNCTION process */
67
68 int main()
69 {
70 /* main */
71 int i;
72
73 init();
74 for (i=0; i<numberOfTimes; i++)
75 {
76 /* while */
77 getInput();
78 process();
79 } /* while */
80
81 return EXIT_SUCCESS;
82 } /* main */
83
84