- 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
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
#include <stdio.h>
int leap(int);
void instruct(void);
int main(void) {
int year, month, day, number;
int jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov;
jan = 31; feb = 28; mar = 31; apr = 30; may = 31; jun = 30;
jul = 31; aug = 31; sep = 30; oct = 31; nov = 30;
instruct();
printf("\nВведите дату в формате DD.MM.YYYY: ");
scanf("%d.%d.%d", &day, &month , &year);
if (leap(year) == 1) {
printf("\nГод високосный.\n");
feb = 29;
}
if (leap(year) == 0)
printf("\nГод не високосный.\n");
switch (month) {
case 1:
number = day;
break;
case 2:
number = jan + day;
break;
case 3:
number = jan + feb + day;
break;
case 4:
number = jan + feb + mar + day;
break;
case 5:
number = jan + feb + mar + apr + day;
break;
case 6:
number = jan + feb + mar + apr + may + day;
break;
case 7:
number = jan + feb + mar + apr + may + jun + day;
break;
case 8:
number = jan + feb + mar + apr + may + jun + jul + day;
break;
case 9:
number = jan + feb + mar + apr + may + jun + jul + aug + day;
break;
case 10:
number = jan + feb + mar + apr + may + jun + jul + aug + sep + day;
break;
case 11:
number = jan + feb + mar + apr + may + jun + jul + aug + sep + oct + day;
break;
case 12:
number = jan + feb + mar + apr + may + jun + jul + aug + sep + oct + nov + day;
break;
default:
number = -1;
}
printf("%d.%d.%d - это день номер %d этого года.\n", day, month , year, number);
return(0);
}
void instruct(void) {
printf("Программа предназначена для определения дня года по заданной дате.\n");
}
int leap(int year) {
if (year % 400 == 0)
return(1);
if (year % 100 == 0)
return(0);
if (year % 4 == 0)
return(1);
return(0);
}