Created
December 1, 2014 15:01
-
-
Save amoshyc/87041f33e7d00a1c58df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| int main() { | |
| const int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | |
| const char* day[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", | |
| "Thursday", "Friday", "Saturday"}; | |
| int T; | |
| scanf("%d", &T); | |
| while (T--) { | |
| int M, D; | |
| scanf("%d %d", &M, &D); | |
| int cnt = 0; | |
| int i; | |
| for(i=1; i<M; i++) | |
| cnt += days[i]; | |
| cnt += D; | |
| /*Jan. 1 is Saturday*/ | |
| /*Calculate the day from Jan.1*/ | |
| printf("%s\n", day[(6+cnt-1) % 7]); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment