Advertisement
anechka_ne_plach

6-3

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