1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7. char strdate[254];
  8. int day = 0, month = 0, year,A;
  9. int yearh = 0;
  10. int yearl = 0;
  11.  
  12. scanf("%s", strdate);
  13.  
  14. char *token = strtok(strdate, ".");
  15. day = strtol(token, NULL, 10);
  16.  
  17. token = strtok(NULL, ".");
  18. month = strtol(token, NULL, 10);
  19.  
  20. token = strtok(NULL, ".");
  21.  
  22. strncpy((char *)&year, token ,2);
  23. yearh = strtol((char *)&year, NULL, 10);
  24.  
  25.  
  26. if(month == 1 || month == 2)
  27. yearl--;
  28.  
  29. int gauss_month[] = {11,12,1,2,3,4,5,6,7,8,9,10};
  30.  
  31. /* A=d+[2.6*m-0.2] + y + [y/4]+[c/4]-2*c */
  32. A = day + (int)((double)2.6*gauss_month[month-1]-0.2) + yearl + (int)((double)yearl/4) + (int)((double)yearh/4) - 2 * yearh;
  33.  
  34. printf("W= %d \n", A % 7);
  35.  
  36. return 0;
  37. }