The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C Code
Posted by: AndiMAtthias | October 20, 2009 @ 2:31pm
C Code
[
Download
]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char strdate[254]; int day = 0, month = 0, year,A; int yearh = 0; int yearl = 0; scanf("%s", strdate); char *token = strtok(strdate, "."); day = strtol(token, NULL, 10); token = strtok(NULL, "."); month = strtol(token, NULL, 10); token = strtok(NULL, "."); strncpy((char *)&year, token ,2); yearh = strtol((char *)&year, NULL, 10); if(month == 1 || month == 2) yearl--; int gauss_month[] = {11,12,1,2,3,4,5,6,7,8,9,10}; /* A=d+[2.6*m-0.2] + y + [y/4]+[c/4]-2*c */ A = day + (int)((double)2.6*gauss_month[month-1]-0.2) + yearl + (int)((double)yearl/4) + (int)((double)yearh/4) - 2 * yearh; printf("W= %d \n", A % 7); return 0; }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.77 / 8
82 Votes