Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <limits.h>
- #include <string.h>
- #include <time.h>
- enum
- {
- SECS_IN_DAY = 60 * 60 * 24,
- DAYS_IN_YEAR = 30 * 12,
- DAYS_IN_MONTH = 30
- };
- void
- count_date(unsigned long long time)
- {
- unsigned long long date = time / SECS_IN_DAY;
- unsigned long long year, month, day;
- year = date / DAYS_IN_YEAR;
- date %= DAYS_IN_YEAR;
- month = date / DAYS_IN_MONTH;
- date %= DAYS_IN_MONTH;
- day = date;
- printf("%lld %lld %lld\n", year + 1, month + 1, day + 1);
- }
- int
- main(void)
- {
- struct tm st = {.tm_sec = 0, .tm_min = 0, .tm_hour = 0,
- .tm_mday = 7, .tm_mon = 9, .tm_isdst = -1, .tm_year = 25};
- unsigned long long start = timegm(&st);
- unsigned int year, month, day;
- while (scanf("%u%u%u", &year, &month, &day) == 3) {
- struct tm tm = {.tm_sec = 0, .tm_min = 0, .tm_hour = 0,
- .tm_mday = day, .tm_mon = month - 1, .tm_isdst = -1, .tm_year = year - 1900};
- unsigned long long time = timegm(&tm);
- count_date(time - start);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement