- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
void calendar(int year){
int i, j, k, frst=1, week, length, day = 0;
printf(" ");
if(year < 1000) printf(" ");
printf("%d\n\n", year);
int first[3]; // число начала недели (первая неделя - любой день недели, следющие - понедельник)
for(i = 1; i <= 4; ++i){
print_tetral(i);
first[1] = weekday(1, 1, 1, 1, 1, i*3-2, year);
first[2] = weekday(1, 1, 1, 1, 1, i*3-1, year);
first[3] = weekday(1, 1, 1, 1, 1, i*3, year);
length = max(weeks_in_month(i*3-2, year), \
weeks_in_month(i*3-1, year), \
weeks_in_month(i*3, year));
for(week = 0; week < length; ++week){
for(j = 1; j <= 3; ++j){
frst = first[j];
if(week > 0) frst = 1;
if(week == 0)
for(k = 1; k < first[j]; ++k)
printf(" ");
k = frst;
day = 0;
while(k <= 7 && day < days_in_month(i*3-3+j, year) && week < weeks_in_month(i*3-3+j, year)){
day = 7*week + k - first[j] + 1;
if(day > days_in_month(i*3-3+j, year)) break;
if(day < 10) printf(" %d ", day);
else if(day >= 10) printf("%d ", day);
++k;
}
if(week == length - 1 || day >= days_in_month(i*3-3+j, year))
for(; k <= 7; ++k)
printf(" ");
printf(" ");
}
printf("\n");
}
printf("\n");
}
}