Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //h= [ q + floor(13*(m-1)/5) + floor(k/4) + floor(j/4) + 5*j ] % 7
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- int h,q,m,k,j,day,month,year;
- printf("Enter the date (dd/mm/yyyy)\n");
- scanf("%i/%i/%i",&day,&month,&year);
- if(month < 3)
- {
- month += 12;
- year--;
- }
- q = day;
- m = month;
- k = year % 100;
- j = year / 100;
- h = q + floor(13*(m+1)/5) + k + floor(k/4) + floor(j/4) + 5 * j;
- h = h % 7;
- switch(h)
- {
- case 0 : printf("Saturday.\n"); break;
- case 1 : printf("Sunday.\n"); break;
- case 2 : printf("Monday. \n"); break;
- case 3 : printf("Tuesday. \n"); break;
- case 4 : printf("Wednesday. \n"); break;
- case 5 : printf("Thurday. \n"); break;
- case 6 : printf("Friday. \n"); break;
- }
- fflush(stdin);
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement