Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include <locale.h>
- void print_calendar(int year, int month)
- {
- int days_in_month[] = { 31, 28 + (year % 4 == 0 && year % 100 != 0 || year % 400 == 0), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- char* month_names[] = { "", "������", "�������", "����", "������", "���", "����", "����", "������", "��������", "�������", "������", "�������" };
- printf("%s %04d\n", month_names[month], year);
- printf("�� �� �� �� �� �� ��\n");
- int dow = get_day_of_week(year, month, 1);
- for (int i = 0; i < dow; i++)
- {
- printf(" ");
- }
- for (int day = 1; day <= days_in_month[month - 1]; day++)
- {
- printf("%2d ", day);
- if ((day + dow) % 7 == 0 || day == days_in_month[month - 1])
- {
- printf("\n");
- }
- }
- }
- int main()
- {
- system("chcp 1251");
- setlocale(LC_ALL, "rus");
- char input[11];
- time_t t = time(NULL);
- struct tm now = *localtime(&t);
- int year = now.tm_year + 1900;
- int month = now.tm_mon + 1;
- int day = now.tm_mday;
- char now1[] = "now";
- printf("������� ���� � ������� ����.��.��, ����.��, ���� ��� now: ");
- scanf("%s", input);
- if (strcmp(input, now1) == 0)
- {
- printf("����������� ����: %04d.%02d.%02d\n", year, month, day);
- }
- else if (strlen(input) == 10 && input[4] == '.' && input[7] == '.')
- {
- struct tm new;
- new.tm_year = atoi(input);
- new.tm_mon = atoi(input + 5);
- new.tm_wday = atoi(input + 8);
- time_t�t;
- struct�tm�* p;
- char�s[80];
- char* format� = "%A�%B�%Y";
- t� = time(NULL);
- p� = gmtime(&t);
- strftime(s, 80, format, p);�
- printf("Time:�%s\n", s);
- return�0;
- }
- time_t t = mktime(timeinfo);
- char buffer[80];
- strftime(buffer, 80, "%A", localtime(&t));
- printf("���� ������: %s\n", buffer);
- int dow = get_day_of_week(year, month, day);
- switch (dow)
- {
- case 0:
- printf("���� ������ ��� ���� %s: �����������\n", input);
- break;
- case 1:
- printf("���� ������ ��� ���� %s: �����������\n", input);
- break;
- case 2:
- printf("���� ������ ��� ���� %s: �������\n", input);
- break;
- case 3:
- printf("���� ������ ��� ���� %s: �����\n", input);
- break;
- case 4:
- printf("���� ������ ��� ���� %s: �������\n", input);
- break;
- case 5:
- printf("���� ������ ��� ���� %s: �������\n", input);
- break;
- case 6:
- printf("���� ������ ��� ���� %s: �������\n", input);
- break;
- default:
- break;
- }
- }
- else if (strlen(input) == 7 && input[4] == '.')
- {
- year = atoi(input);
- month = atoi(input + 5);
- printf("��������� �� %04d.%02d:\n", year, month);
- print_calendar(year, month);
- }
- else if (strlen(input) == 4)
- {
- year = atoi(input);
- printf("��������� �� %04d:\n", year);
- for (int i = 1; i <= 12; i++)
- {
- print_calendar(year, i);
- }
- }
- else
- {
- printf("������: ������������ ������ ����\n");
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement