Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- │ File: kr06/3/kr06-3.c
- ───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
- 1 │ #include <stdio.h>
- 2 │ #include <time.h>
- 3 │ #include <stdint.h>
- 4 │ #include <limits.h>
- 5 │
- 6 │ enum { DATE_SIZE = 20 };
- 7 │
- 8 │ int main() {
- 9 │ time_t rawtime;
- 10 │ struct tm *info;
- 11 │
- 12 │ int year, month, day, length;
- 13 │ scanf("%d-%d-%d %d", &year, &month, &day, &length);
- 14 │
- 15 │ time(&rawtime);
- 16 │ info = localtime(&rawtime);
- 17 │ info->tm_year = year - 1900;
- 18 │ info->tm_mon = month - 1;
- 19 │ info->tm_mday = day;
- 20 │
- 21 │ mktime(info);
- 22 │ length *= 2;
- 23 │
- 24 │
- 25 │
- 26 │ for (int i = 0; i < length; ++i) {
- 27 │ info->tm_year = year - 1900;
- 28 │ info->tm_mon = month - 1;
- 29 │ info->tm_mday = day;
- 30 │ info->tm_mon += 6 * (i + 1);
- 31 │ mktime(info);
- 32 │ while (info->tm_wday == 0 || info->tm_wday == 6) {
- 33 │ info->tm_mday++;
- 34 │ mktime(info);
- 35 │ }
- 36 │ char buf[DATE_SIZE];
- 37 │ strftime(buf, DATE_SIZE, "%Y-%m-%d", info);
- 38 │ printf("%s\n", buf);
- 39 │ }
- 40 │ }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement