The_Law

Untitled

Oct 29th, 2018
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <zconf.h>
  4. #include <time.h>
  5.  
  6. enum
  7. {
  8.     SUNDAY_NUM = 7,
  9.     START_YEAR = 1900
  10. };
  11.  
  12. int
  13. main(int argc, char *argv[])
  14. {
  15.     int y = atoi(argv[1]);
  16.     int d = atoi(argv[2]);
  17.     struct tm date = {};
  18.     date.tm_year = y - START_YEAR;
  19.     date.tm_mday = d;
  20.     mktime(&date);
  21.     date.tm_year += START_YEAR;
  22.     date.tm_wday = date.tm_wday == 0 ? SUNDAY_NUM : date.tm_wday;
  23.     printf ("%d %d %d %d\n", date.tm_year, date.tm_mon + 1, date.tm_mday, date.tm_wday);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment